public override object ChangeType (object value, Type type, CultureInfo culture)
{
if (value == null)
return null;
Type vtype = value.GetType ();
if (type.IsByRef)
type = type.GetElementType ();
if (vtype == type || type.IsInstanceOfType (value))
return value;
if (vtype.IsArray && type.IsArray){
if (IsArrayAssignable (vtype.GetElementType (), type.GetElementType ()))
return value;
}
if (check_type (vtype, type)) {
// These are not supported by Convert
if (type.IsEnum)
return Enum.ToObject (type, value);
if (vtype == typeof (Char)) {
if (type == typeof (double))
return (double)(char)value;
if (type == typeof (float))
return (float)(char)value;
}
if (vtype == typeof (IntPtr) && type.IsPointer)
return value;
return Convert.ChangeType (value, type);
}
return null;
}