예제 #1
0
 protected override int FindCore(PropertyDescriptor prop, object key)
 {
     if (key is T)
     {
         GenericIComparer <T> comparer = GenericComparerFactory.GetComparer <T>(prop.Name, false);
         for (Int32 index = 0; index < Items.Count; ++index)
         {
             if (comparer.Compare(Items[index], (T)key) == 0)
             {
                 return(index);
             }
         }
         return(-1);
     }
     throw new NotSupportedException("Cannot compare Apple With Orange");
 }
예제 #2
0
        private void InnerPerformSort()
        {
            if (_currentSortPropertyDescriptor == null)
            {
                return;
            }
            List <T> temp = Items.ToList();

            Items.Clear();
            GenericIComparer <T> cmp = GenericComparerFactory.GetComparer <T>(_currentSortPropertyDescriptor.Name, _currentSortDirection == ListSortDirection.Descending);

            temp.Sort(cmp);
            foreach (T element in temp)
            {
                Items.Add(element);
            }
        }