Author: zoltan
Date: 2005-05-25 08:04:56 -0400 (Wed, 25 May 2005)
New Revision: 44992

Modified:
   trunk/mcs/class/corlib/System/ChangeLog
   trunk/mcs/class/corlib/System/Type.cs
Log:
2005-05-25  Zoltan Varga  <[EMAIL PROTECTED]>

        * Type.cs: Improve support for user defined type subclasses.


Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog     2005-05-25 11:20:21 UTC (rev 
44991)
+++ trunk/mcs/class/corlib/System/ChangeLog     2005-05-25 12:04:56 UTC (rev 
44992)
@@ -1,3 +1,7 @@
+2005-05-25  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * Type.cs: Improve support for user defined type subclasses.
+
 2005-05-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * DateTime.cs : Added minimum digit parameter to ParseNumber() to

Modified: trunk/mcs/class/corlib/System/Type.cs
===================================================================
--- trunk/mcs/class/corlib/System/Type.cs       2005-05-25 11:20:21 UTC (rev 
44991)
+++ trunk/mcs/class/corlib/System/Type.cs       2005-05-25 12:04:56 UTC (rev 
44992)
@@ -212,7 +212,7 @@
                                        return true;
                                if (IsInterface)
                                        return false;
-                               return !type_is_subtype_of (this, typeof 
(System.ValueType), false);
+                               return !is_subtype_of (this, typeof 
(System.ValueType), false);
                        }
                }
 
@@ -230,7 +230,7 @@
 
                public bool IsEnum {
                        get {
-                               return type_is_subtype_of (this, typeof 
(System.Enum), false) &&
+                               return is_subtype_of (this, typeof 
(System.Enum), false) &&
                                        this != typeof (System.Enum);
                        }
                }
@@ -335,7 +335,7 @@
                        get {
                                // Enums and delegates are always serializable
                                return (Attributes & 
TypeAttributes.Serializable) != 0 || IsEnum || 
-                                       type_is_subtype_of (this, typeof 
(System.Delegate), false);
+                                       is_subtype_of (this, typeof 
(System.Delegate), false);
                        }
                }
 
@@ -456,9 +456,13 @@
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                public extern static TypeCode GetTypeCodeInternal (Type type);
 
-               public static TypeCode GetTypeCode (Type type)
-               {
-                       return GetTypeCodeInternal (type);
+               public static TypeCode GetTypeCode (Type type) {
+                       type = type.UnderlyingSystemType;
+
+                       if (!type.IsSystemType)
+                               return Type.GetTypeCode (typeof (object));
+                       else
+                               return GetTypeCodeInternal (type);
                }
 
                [MonoTODO]
@@ -524,13 +528,24 @@
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                internal static extern bool type_is_assignable_from (Type a, 
Type b);
-               
+
+               internal static bool is_subtype_of (Type a, Type b, bool 
check_interfaces)
+               {
+                       a = a.UnderlyingSystemType;
+                       b = b.UnderlyingSystemType;
+
+                       if (!a.IsSystemType || !b.IsSystemType)
+                               return false;
+                       else
+                               return type_is_subtype_of (a, b, 
check_interfaces);
+               }
+
                public virtual bool IsSubclassOf (Type c)
                {
                        if (c == null)
                                return false;
 
-                       return (this != c) && type_is_subtype_of (this, c, 
false);
+                       return (this != c) && is_subtype_of (this, c, false);
                }
 
                public virtual Type[] FindInterfaces (TypeFilter filter, object 
filterCriteria)
@@ -584,6 +599,21 @@
                        if (c is TypeBuilder)
                                return ((TypeBuilder)c).IsAssignableTo (this);
 
+                       /* Handle user defined type classes */
+                       if (!IsSystemType) {
+                               Type systemType = UnderlyingSystemType;
+                               if (!systemType.IsSystemType)
+                                       return false;
+                               return systemType.IsAssignableFrom (c);
+                       }
+
+                       if (!c.IsSystemType) {
+                               Type underlyingType = c.UnderlyingSystemType;
+                               if (!underlyingType.IsSystemType)
+                                       return false;
+                               return IsAssignableFrom (underlyingType);
+                       }
+
                        return type_is_assignable_from (this, c);
                }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to