Author: miguel
Date: 2006-11-28 18:08:03 -0500 (Tue, 28 Nov 2006)
New Revision: 68627

Modified:
   trunk/mcs/class/System/System.ComponentModel/ChangeLog
   trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
Log:
2006-11-28  Miguel de Icaza  <[EMAIL PROTECTED]>

        * TypeDescriptor.cs: This implementation is really from Gonzalo,
        he dictated to me :-)




Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog      2006-11-28 
22:49:44 UTC (rev 68626)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog      2006-11-28 
23:08:03 UTC (rev 68627)
@@ -1,3 +1,8 @@
+2006-11-28  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * TypeDescriptor.cs: This implementation is really from Gonzalo,
+       he dictated to me :-)
+
 2006-11-20  Nagappan A  <[EMAIL PROTECTED]>
 
        * ISupportInitializeNotification.cs: New Interface file to support

Modified: trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs      
2006-11-28 22:49:44 UTC (rev 68626)
+++ trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs      
2006-11-28 23:08:03 UTC (rev 68627)
@@ -399,12 +399,29 @@
                return GetEditor (component, editorBaseType, false);
        }
 
-       [MonoTODO]
        public static object GetEditor (object component, Type editorBaseType, 
bool noCustomTypeDesc)
        {
+               if (component == null)
+                       throw new ArgumentNullException ("component");
+               if (editorBaseType == null)
+                       throw new ArgumentNullException ("editorBaseType");
+               
                if (!noCustomTypeDesc && (component is ICustomTypeDescriptor))
                        return ((ICustomTypeDescriptor) component).GetEditor 
(editorBaseType);
-               throw new NotImplementedException ();
+
+               object [] atts = component.GetType ().GetCustomAttributes 
(typeof (EditorAttribute), true);
+               if (atts.Length == 0)
+                       return null;
+               string target = editorBaseType.AssemblyQualifiedName;
+               
+               foreach (EditorAttribute ea in atts){
+                       if (ea.EditorBaseTypeName == target){
+                               Type t = Type.GetType (ea.EditorTypeName, true);
+
+                               return Activator.CreateInstance (t);
+                       }
+               }
+               return null;
        }
 
        public static EventDescriptorCollection GetEvents (object component)

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

Reply via email to