System.ComponentModel.EventDescriptorCollection.InternalSort C# (CSharp) Method

InternalSort() protected method

protected InternalSort ( string names ) : void
names string
return void
        protected void InternalSort(string[] names) {
            if (events == null || events.Length == 0) {
                return;
            }  
            
            this.InternalSort(this.comparer);
            
            if (names != null && names.Length > 0) {
            
               ArrayList eventArrayList = new ArrayList(events);
               int foundCount = 0;
               int eventCount = events.Length;
               
               for (int i = 0; i < names.Length; i++) {
                    for (int j = 0; j < eventCount; j++) {
                        EventDescriptor currentEvent = (EventDescriptor)eventArrayList[j];
                        
                        // Found a matching event.  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 (currentEvent != null && currentEvent.Name.Equals(names[i])) {
                            events[foundCount++] = currentEvent;
                            eventArrayList[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 < eventCount; i++) {
                   if (eventArrayList[i] != null) {
                       events[foundCount++] = (EventDescriptor)eventArrayList[i];
                   }
               }
               
               Debug.Assert(foundCount == eventCount, "We did not completely fill our event array");
            }
        }
        

Same methods

EventDescriptorCollection::InternalSort ( IComparer sorter ) : void

Usage Example

Example #1
0
        public virtual EventDescriptorCollection Sort(IComparer comparer)
        {
            EventDescriptorCollection col = CloneCollection();

            col.InternalSort(comparer);
            return(col);
        }
All Usage Examples Of System.ComponentModel.EventDescriptorCollection::InternalSort