Пример #1
0
        public MyObservableSublist(MyObservableList <T> parentList, SublistSortOption sortOption, IFilter <T> filter, IComparer <T> comparer, InsertAdapter <T> insertAdapter)
        {
            if (parentList == null)
            {
                throw new ArgumentNullException("parentList cannot be null");
            }

            base.Filter        = filter;
            base.Comparer      = comparer;
            base.InsertAdapter = insertAdapter;

            ParentList = parentList;
            SortOption = sortOption;

            Reset();

            parentList.CollectionChanged += parentList_CollectionChanged;
        }
Пример #2
0
        /// <summary>
        /// Generates a sublist from the current list, using the given filter. Sublist continues to update with main list.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public MyObservableList <T> Sublist(IFilter <T> filter, SublistSortOption sortOption = SublistSortOption.UseComparer)
        {
            switch (sortOption)
            {
            case SublistSortOption.UseComparer:
                MyObservableList <T> list = new MyObservableList <T>()
                {
                    Filter        = filter,
                    Comparer      = Comparer,
                    InsertAdapter = InsertAdapter
                };

                list.InsertSorted(this);

                return(list);


            case SublistSortOption.SameAsParentList:
                return(new MyObservableSublistSortSameAsParent <T>(this, filter, InsertAdapter));

            default:
                throw new NotImplementedException();
            }
        }
Пример #3
0
 internal MyObservableSublistSortSameAsParent(MyObservableList <T> parentList, IFilter <T> filter, InsertAdapter <T> insertAdapter)
     : base(parentList, SublistSortOption.SameAsParentList, filter, null, insertAdapter)
 {
 }