Author: lluis
Date: 2005-04-13 04:53:39 -0400 (Wed, 13 Apr 2005)
New Revision: 42893

Modified:
   trunk/mcs/class/System/System.ComponentModel/ChangeLog
   trunk/mcs/class/System/System.ComponentModel/PropertyDescriptor.cs
   trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
Log:
2005-04-13  LLuis Sanchez Gual  <[EMAIL PROTECTED]>

        * TypeDescriptor.cs: When creating a converter, use a constructor that
        takes a Type parameter if exists.
        * PropertyDescriptor.cs: In the Converter property, check for a
        TypeConverterAttribute in the property.



Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog      2005-04-13 
08:06:20 UTC (rev 42892)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog      2005-04-13 
08:53:39 UTC (rev 42893)
@@ -1,3 +1,10 @@
+2005-04-13  LLuis Sanchez Gual  <[EMAIL PROTECTED]>
+
+       * TypeDescriptor.cs: When creating a converter, use a constructor that
+       takes a Type parameter if exists.
+       * PropertyDescriptor.cs: In the Converter property, check for a
+       TypeConverterAttribute in the property.
+
 2005-03-02  Jackson Harper  <[EMAIL PROTECTED]>
 
        * ReflectionEventDescriptor.cs: Bind handlers to the actual event so 
that

Modified: trunk/mcs/class/System/System.ComponentModel/PropertyDescriptor.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/PropertyDescriptor.cs  
2005-04-13 08:06:20 UTC (rev 42892)
+++ trunk/mcs/class/System/System.ComponentModel/PropertyDescriptor.cs  
2005-04-13 08:53:39 UTC (rev 42893)
@@ -40,6 +40,8 @@
        [ComVisible (true)]
        public abstract class PropertyDescriptor : MemberDescriptor
        {
+               TypeConverter converter;
+
                protected PropertyDescriptor (MemberDescriptor reference)
                : base (reference)
                {
@@ -58,7 +60,22 @@
                public abstract Type ComponentType { get; }
 
                public virtual TypeConverter Converter {
-                       get { return TypeDescriptor.GetConverter 
(PropertyType); }
+                       get {
+                               if (converter == null) {
+                                       TypeConverterAttribute at = 
(TypeConverterAttribute) Attributes [typeof(TypeConverterAttribute)];
+                                       if (at == null || at == 
TypeConverterAttribute.Default)
+                                               converter = 
TypeDescriptor.GetConverter (PropertyType);
+                                       else {
+                                               Type t = Type.GetType 
(at.ConverterTypeName);
+                                               ConstructorInfo ci = 
t.GetConstructor (new Type[] { typeof(Type) });
+                                               if (ci != null)
+                                                       converter = 
(TypeConverter) ci.Invoke (new object[] { PropertyType });
+                                               else
+                                                       converter = 
(TypeConverter) Activator.CreateInstance (t);
+                                       }
+                               }
+                               return converter;
+                       }
                }
 
                public virtual bool IsLocalizable {

Modified: trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs      
2005-04-13 08:06:20 UTC (rev 42892)
+++ trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs      
2005-04-13 08:53:39 UTC (rev 42893)
@@ -189,8 +189,13 @@
                                t = GetTypeFromName (component as IComponent, 
tca.ConverterTypeName);
                        }
                        
-                       if (t != null)
-                               return (TypeConverter) Activator.CreateInstance 
(t);
+                       if (t != null) {
+                               ConstructorInfo ci = t.GetConstructor (new 
Type[] { typeof(Type) });
+                               if (ci != null)
+                                       return (TypeConverter) ci.Invoke (new 
object[] { component.GetType () });
+                               else
+                                       return (TypeConverter) 
Activator.CreateInstance (t);
+                       }
                        else
                                return GetConverter (component.GetType ());
                }

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

Reply via email to