Merge pull request #439 from mono-soc-2012/garyb/iconfix
[mono.git] / mcs / class / System / System.ComponentModel / PropertyDescriptorCollection.cs
index 2982858c2a609af815cff2a30f538450adc6aced..b7fa48ad0ad25890d1477647a8a160eed670adf0 100644 (file)
@@ -52,12 +52,7 @@ namespace System.ComponentModel
                        this.properties.AddRange (properties);
                }
 
-#if NET_2_0
-               public
-#else
-               internal
-#endif
-               PropertyDescriptorCollection (PropertyDescriptor[] properties, bool readOnly) : this (properties)
+               public PropertyDescriptorCollection (PropertyDescriptor[] properties, bool readOnly) : this (properties)
                {
                        this.readOnly = readOnly;
                }
@@ -139,24 +134,19 @@ namespace System.ComponentModel
 
                public virtual PropertyDescriptor Find (string name, bool ignoreCase)
                {
-                       if (name == null) {
+                       if (name == null)
                                throw new ArgumentNullException ("name");
-                       }
 
-#if TARGET_JVM
-                       if (!ignoreCase)
-                       {
-                               foreach (PropertyDescriptor p in properties) 
-                               {
-                                       if (String.Equals (name, p.Name))
-                                               return p;                               
+                       for (int i = 0; i < properties.Count; ++i) {
+                               PropertyDescriptor p = (PropertyDescriptor)properties [i];
+                               if (ignoreCase) {
+                                       if (0 == String.Compare (name, p.Name, StringComparison.OrdinalIgnoreCase))
+                                               return p;
+                               }
+                               else {
+                                       if (0 == String.Compare (name, p.Name, StringComparison.Ordinal))
+                                               return p;
                                }
-                               return null;
-                       }
-#endif
-                       foreach (PropertyDescriptor p in properties) {
-                               if (0 == String.Compare (name, p.Name, ignoreCase))
-                                       return p;
                        }
                        return null;
                }
@@ -166,18 +156,17 @@ namespace System.ComponentModel
                        return properties.GetEnumerator ();
                }
 
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return GetEnumerator ();
+               }
+
                [MonoTODO]
                IDictionaryEnumerator IDictionary.GetEnumerator ()
                {
                        throw new NotImplementedException ();
                }
 
-#if TARGET_JVM
-               IEnumerator IEnumerable.GetEnumerator ()
-               {
-                       return GetEnumerator ();
-               }
-#endif
                public int IndexOf (PropertyDescriptor value)
                {
                        return properties.IndexOf (value);
@@ -269,24 +258,34 @@ namespace System.ComponentModel
                public virtual PropertyDescriptorCollection Sort (string[] order, IComparer comparer) 
                {
                        PropertyDescriptorCollection col = CloneCollection ();
-                       ArrayList sorted = col.ExtractItems (order);
-                       col.InternalSort (comparer);
-                       sorted.AddRange (col.properties);
-                       col.properties = sorted;
+                       if (order != null) {
+                               ArrayList sorted = col.ExtractItems (order);
+                               col.InternalSort (comparer);
+                               sorted.AddRange (col.properties);
+                               col.properties = sorted;
+                       } else {
+                               col.InternalSort (comparer);
+                       }
                        return col;
                }
 
                protected void InternalSort (IComparer ic)
                {
+                       if (ic == null)
+                               ic = MemberDescriptor.DefaultComparer;
                        properties.Sort (ic);
                }
 
                protected void InternalSort (string [] order)
                {
-                       ArrayList sorted = ExtractItems (order);
-                       InternalSort ((IComparer) null);
-                       sorted.AddRange (properties);
-                       properties = sorted;
+                       if (order != null) {
+                               ArrayList sorted = ExtractItems (order);
+                               InternalSort ((IComparer) null);
+                               sorted.AddRange (properties);
+                               properties = sorted;
+                       } else {
+                               InternalSort ((IComparer) null);
+                       }
                }
                
                ArrayList ExtractItems (string[] names)
@@ -335,11 +334,7 @@ namespace System.ComponentModel
                {
                        get 
                        {
-#if NET_2_0
                                return readOnly;
-#else
-                               return !readOnly;
-#endif
                        }
                }
 #if TARGET_JVM //DUAL_IFACE_CONFLICT