Author: toshok
Date: 2006-11-08 11:54:58 -0500 (Wed, 08 Nov 2006)
New Revision: 67543
Modified:
trunk/mcs/class/System/System.ComponentModel/ArrayConverter.cs
trunk/mcs/class/System/System.ComponentModel/ChangeLog
Log:
2006-11-08 Chris Toshok <[EMAIL PROTECTED]>
* ArrayConverter.cs: implement GetProperties correctly, by
creating ArrayPropertyDescriptor objects for each array element.
Modified: trunk/mcs/class/System/System.ComponentModel/ArrayConverter.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ArrayConverter.cs
2006-11-08 16:46:25 UTC (rev 67542)
+++ trunk/mcs/class/System/System.ComponentModel/ArrayConverter.cs
2006-11-08 16:54:58 UTC (rev 67543)
@@ -51,14 +51,75 @@
public override PropertyDescriptorCollection GetProperties
(ITypeDescriptorContext context,
object value, Attribute[] attributes)
{
- // LAMESPEC MS seems to always parse an
PropertyDescriptorCollection without any PropertyDescriptors
- return PropertyDescriptorCollection.Empty;
+ PropertyDescriptorCollection col = new
PropertyDescriptorCollection (null);
+ if (value is Array) {
+ Array array = (Array)value;
+ for (int i = 0; i < array.Length; i ++) {
+ col.Add (new ArrayPropertyDescriptor
(i, array.GetType()));
+ }
+ }
+
+ return col;
}
public override bool GetPropertiesSupported
(ITypeDescriptorContext context)
{
return true;
}
+
+ internal class ArrayPropertyDescriptor : PropertyDescriptor
+ {
+ int index;
+ Type array_type;
+ public ArrayPropertyDescriptor (int index, Type
array_type)
+ : base (String.Format ("[{0}]", index), null)
+ {
+ this.index = index;
+ this.array_type = array_type;
+ }
+
+ public override Type ComponentType {
+ get { return array_type; }
+ }
+
+ public override Type PropertyType {
+ get { return array_type.GetElementType(); }
+ }
+
+ public override bool IsReadOnly {
+ get { return false; }
+ }
+
+ public override object GetValue (object component)
+ {
+ if (component == null)
+ return null;
+
+ return ((Array)component).GetValue (index);
+ }
+
+ public override void SetValue (object component, object
value)
+ {
+ if (component == null)
+ return;
+
+ ((Array)component).SetValue (value, index);
+ }
+
+ public override void ResetValue (object component)
+ {
+ }
+
+ public override bool CanResetValue (object component)
+ {
+ return false;
+ }
+
+ public override bool ShouldSerializeValue (object
component)
+ {
+ return false;
+ }
+ }
}
}
Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog 2006-11-08
16:46:25 UTC (rev 67542)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog 2006-11-08
16:54:58 UTC (rev 67543)
@@ -1,3 +1,8 @@
+2006-11-08 Chris Toshok <[EMAIL PROTECTED]>
+
+ * ArrayConverter.cs: implement GetProperties correctly, by
+ creating ArrayPropertyDescriptor objects for each array element.
+
2006-10-05 Andrew Skiba <[EMAIL PROTECTED]>
* EventHandlerList.cs: Implement event handler list according to MS
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches