System.ComponentModel.PropertyDescriptorCollection.InternalSort C# (CSharp) Méthode

InternalSort() protected méthode

protected InternalSort ( string names ) : void
names string
Résultat void
        protected void InternalSort(string[] names) {
            if (properties == null || properties.Length == 0) {
                return;
            }  
            
            this.InternalSort(this.comparer);
            
            if (names != null && names.Length > 0) {
            
               ArrayList propArrayList = new ArrayList(properties);
               int foundCount = 0;
               int propCount = properties.Length;
               
               for (int i = 0; i < names.Length; i++) {
                    for (int j = 0; j < propCount; j++) {
                        PropertyDescriptor currentProp = (PropertyDescriptor)propArrayList[j];
                        
                        // Found a matching property.  Here, we add it to our array.  We also
                        // mark it as null in our array list so we don't add it twice later.
                        //
                        if (currentProp != null && currentProp.Name.Equals(names[i])) {
                            properties[foundCount++] = currentProp;
                            propArrayList[j] = null;
                            break;
                        }
                    }
               }
                
               // At this point we have filled in the first "foundCount" number of propeties, one for each
               // name in our name array.  If a name didn't match, then it is ignored.  Next, we must fill
               // in the rest of the properties.  We now have a sparse array containing the remainder, so
               // it's easy.
               //
               for (int i = 0; i < propCount; i++) {
                   if (propArrayList[i] != null) {
                       properties[foundCount++] = (PropertyDescriptor)propArrayList[i];
                   }
               }
               
               Debug.Assert(foundCount == propCount, "We did not completely fill our property array");
            }
        }
        

Same methods

PropertyDescriptorCollection::InternalSort ( IComparer sorter ) : void

Usage Example

Exemple #1
0
        public virtual PropertyDescriptorCollection Sort(string[] order, IComparer comparer)
        {
            PropertyDescriptorCollection col = CloneCollection();

            if (order != null)
            {
                ArrayList sorted = col.ExtractItems(order);
                col.InternalSort(comparer);
                sorted.AddRange(col.properties);
                col.properties = sorted;
            }
            else
            {
                col.InternalSort(comparer);
            }
            return(col);
        }
All Usage Examples Of System.ComponentModel.PropertyDescriptorCollection::InternalSort