示例#1
0
        public static AsyncObservableCollection <T> GetItems <T>(AsyncObservableCollection <T> collection, DummyItemType collectionType) where T : StoreItem, new()
        {
            AsyncObservableCollection <T> items = collection.ToCollection();

            items.Sort((x, y) => x.Title.CompareTo(y.Title));

            if (collectionType == DummyItemType.NoneType || collectionType == DummyItemType.AllNoneType)
            {
                T item = StoreItem.GetDummyItem <T>(DummyItemType.NoneType);
                items.Insert(0, item);
            }

            if (collectionType == DummyItemType.AllType || collectionType == DummyItemType.AllNoneType)
            {
                T item = StoreItem.GetDummyItem <T>(DummyItemType.AllType);
                items.Insert(0, item);
            }

            return(items);
        }
示例#2
0
        public static AsyncObservableCollection <T> GetItems <T>(AsyncObservableCollection <T> collection, DummyItemType collectionType, string sortPropName) where T : StoreItem, new()
        {
            AsyncObservableCollection <T> items = collection.ToCollection();

            if (collectionType == DummyItemType.NoneType || collectionType == DummyItemType.AllNoneType)
            {
                T item = StoreItem.GetDummyItem <T>(DummyItemType.NoneType);
                items.Add(item);
            }

            if (collectionType == DummyItemType.AllType || collectionType == DummyItemType.AllNoneType)
            {
                T item = StoreItem.GetDummyItem <T>(DummyItemType.AllType);
                items.Add(item);
            }

            ItemPropertySort <T> itemComparer = new ItemPropertySort <T>(sortPropName, System.ComponentModel.ListSortDirection.Ascending);

            items.Sort((x, y) => itemComparer.Compare(x, y));

            return(items);
        }