public bool Convert(Type targetType, object owner, ref object value)
{
if (value == null)
// todo nullable check
return !typeof(ValueType).IsAssignableFrom(targetType);
var valueType = value.GetType();
if (targetType.IsAssignableFrom(valueType))
return true;
if (targetType == typeof(string) && !(value is string) && !(value is char))
throw new ImmediateStop();
if (targetType == typeof(char) && !(value is char) && (!(value is string) || ((string)value).Length != 1))
throw new ImmediateStop();
if (targetType == typeof(bool) && !(value is bool))
throw new ImmediateStop();
if (targetType.IsEnum && !IsNumber(valueType))
throw new ImmediateStop();
if (IsNumber(targetType) &&
(!IsNumber(valueType) ||
!IsInRange((decimal)value, targetType)))
throw new ImmediateStop();
return false;
}