Ejemplo n.º 1
0
        protected override void ApplySortCore(PropertyDescriptor property, ListSortDirection direction)
        {
            List <T> items = Items as List <T>;

            if (items != null)
            {
                GenericIComparer <T> comparer = GenericComparerFactory.GetComparer <T>(property.Name, direction);
                items.Sort(comparer);
                isSorted = true;
            }
            OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
        }
Ejemplo n.º 2
0
        protected override int FindCore(PropertyDescriptor property, object key)
        {
            if (!(key is T))
            {
                throw new ArgumentException("Incompatible object type", "key");
            }
            GenericIComparer <T> comparer = GenericComparerFactory.GetComparer <T>(property.Name);

            for (Int32 index = 0; index < Items.Count; ++index)
            {
                if (comparer.Compare(Items[index], (T)key) == 0)
                {
                    return(index);
                }
            }
            return(-1);
        }