Author: gonzalo
Date: 2005-04-28 02:22:47 -0400 (Thu, 28 Apr 2005)
New Revision: 43706
Modified:
trunk/mcs/class/System/System.ComponentModel/ChangeLog
trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
Log:
2005-04-28 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* TypeDescriptor.cs: implemented GetEditor. Patch by Jonathan Chambers.
Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog 2005-04-28
04:01:16 UTC (rev 43705)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog 2005-04-28
06:22:47 UTC (rev 43706)
@@ -1,3 +1,7 @@
+2005-04-28 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * TypeDescriptor.cs: implemented GetEditor. Patch by Jonathan Chambers.
+
2005-04-25 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* DefaultValueAttribute.cs: fixed the .ctor that takes a type and a
Modified: trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
2005-04-28 04:01:16 UTC (rev 43705)
+++ trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
2005-04-28 06:22:47 UTC (rev 43706)
@@ -351,10 +351,37 @@
}
}
- [MonoTODO]
public static object GetEditor (Type componentType, Type editorBaseType)
{
- throw new NotImplementedException ();
+ Type t = null;
+ object [] atts = componentType.GetCustomAttributes
(typeof(EditorAttribute), true);
+ if (atts == null || atts.Length == 0)
+ return null;
+
+
+ foreach (EditorAttribute ea in atts)
+ {
+ t = GetTypeFromName (null, ea.EditorTypeName);
+ if (t.IsSubclassOf(editorBaseType))
+ break;
+ }
+
+ if (t != null) {
+ Exception exc = null;
+ try {
+ return Activator.CreateInstance (t);
+ } catch (MissingMethodException e) {
+ exc = e;
+ }
+
+ try {
+ return Activator.CreateInstance (t, new object
[] {componentType});
+ } catch (MissingMethodException e) {
+ throw exc;
+ }
+ }
+
+ return null; // No editor specified
}
public static object GetEditor (object component, Type editorBaseType)
@@ -757,4 +784,3 @@
}
}
}
-
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches