Exemplo n.º 1
0
        public virtual EventDescriptorCollection Sort(string[] order, IComparer comparer)
        {
            EventDescriptorCollection col = CloneCollection();
            ArrayList sorted = col.ExtractItems(order);

            col.InternalSort(comparer);
            sorted.AddRange(col.eventList);
            col.eventList = sorted;
            return(col);
        }
        /// <summary>Sorts the members of this <see cref="T:System.ComponentModel.EventDescriptorCollection" />, given a specified sort order and an <see cref="T:System.Collections.IComparer" />.</summary>
        /// <returns>The new <see cref="T:System.ComponentModel.EventDescriptorCollection" />.</returns>
        /// <param name="names">An array of strings describing the order in which to sort the <see cref="T:System.ComponentModel.EventDescriptor" /> objects in the collection. </param>
        /// <param name="comparer">An <see cref="T:System.Collections.IComparer" /> to use to sort the <see cref="T:System.ComponentModel.EventDescriptor" /> objects in this collection. </param>
        public virtual EventDescriptorCollection Sort(string[] order, IComparer comparer)
        {
            EventDescriptorCollection eventDescriptorCollection = this.CloneCollection();

            if (order != null)
            {
                ArrayList arrayList = eventDescriptorCollection.ExtractItems(order);
                eventDescriptorCollection.InternalSort(comparer);
                arrayList.AddRange(eventDescriptorCollection.eventList);
                eventDescriptorCollection.eventList = arrayList;
            }
            else
            {
                eventDescriptorCollection.InternalSort(comparer);
            }
            return(eventDescriptorCollection);
        }