2006-11-28 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Tue, 28 Nov 2006 23:08:03 +0000 (23:08 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 28 Nov 2006 23:08:03 +0000 (23:08 -0000)
* TypeDescriptor.cs: This implementation is really from Gonzalo,
he dictated to me :-)

svn path=/trunk/mcs/; revision=68627

mcs/class/System/System.ComponentModel/ChangeLog
mcs/class/System/System.ComponentModel/TypeDescriptor.cs

index 186885a1694a16750546bfb31226bdc3d4a0edca..cdf62da6e4719114c150491d3b3aec809eacd6ff 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-28  Miguel de Icaza  <miguel@novell.com>
+
+       * TypeDescriptor.cs: This implementation is really from Gonzalo,
+       he dictated to me :-)
+
 2006-11-20  Nagappan A  <anagappan@novell.com>
 
        * ISupportInitializeNotification.cs: New Interface file to support
index a17e087d85c9de7f154fc96bf4b8c75742ebf349..91b78bd8e15b8dbc5a45401309c9d184bb698552 100644 (file)
@@ -399,12 +399,29 @@ public sealed class TypeDescriptor
                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)