Moved ProviderCollectionTest.cs from System assembly to System.Configuration.
[mono.git] / mcs / class / corlib / System.Reflection / Binder.cs
index 323db37245444359d0064149c0a3b702b7c5c00e..898d4ad38489227329ceb132e21f1772fef0f7aa 100644 (file)
@@ -212,8 +212,18 @@ namespace System.Reflection
                                                return value;
                                }
 
-                               if (check_type (vtype, type))
+                               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;
+                                       }
                                        return Convert.ChangeType (value, type);
+                               }
                                return null;
                        }
 
@@ -231,15 +241,21 @@ namespace System.Reflection
                                if (from == null)
                                        return true;
 
-                               TypeCode fromt = Type.GetTypeCode (from);
-                               TypeCode tot = Type.GetTypeCode (to);
-
                                if (to.IsByRef != from.IsByRef)
                                        return false;
 
                                if (to.IsInterface)
                                        return to.IsAssignableFrom (from);
 
+                               if (to.IsEnum) {
+                                       to = Enum.GetUnderlyingType (to);
+                                       if (from == to)
+                                               return true;
+                               }
+
+                               TypeCode fromt = Type.GetTypeCode (from);
+                               TypeCode tot = Type.GetTypeCode (to);
+
                                switch (fromt) {
                                case TypeCode.Char:
                                        switch (tot) {
@@ -499,7 +515,7 @@ namespace System.Reflection
                                        if (idxlen >= 0 && idxlen != args.Length)
                                                continue;
 
-                                       if (haveRet && !check_type (p.PropertyType, returnType))
+                                       if (haveRet && p.PropertyType != returnType)
                                                continue;
 
                                        int score = Int32.MaxValue - 1;