internal LiveShapingList(ICollectionViewLiveShaping view, LiveShapingFlags flags, IComparer comparer)
        {
            _view            = view;
            _comparer        = comparer;
            _isCustomSorting = !(comparer is SortFieldComparer);
            _dpFromPath      = new DPFromPath();
            _root            = new LiveShapingTree(this);

            if (comparer != null)
            {
                _root.Comparison = CompareLiveShapingItems;
            }

            _sortDirtyItems   = new List <LiveShapingItem>();
            _filterDirtyItems = new List <LiveShapingItem>();
            _groupDirtyItems  = new List <LiveShapingItem>();

            SetLiveShapingProperties(flags);
        }
 public void Clear()
 {
     ForEach((x) => { ClearItem(x); });
     _root = new LiveShapingTree(this);
 }
        // reset the collections of properties to observe, and their
        // corresponding DPs
        internal void SetLiveShapingProperties(LiveShapingFlags flags)
        {
            int    k, n;
            string path;

            _dpFromPath.BeginReset();

            // Sorting //

            // get the properties used for comparison
            SortDescriptionCollection sdc = ((ICollectionView)View).SortDescriptions;

            n          = sdc.Count;
            _compInfos = new LivePropertyInfo[n];
            for (k = 0; k < n; ++k)
            {
                path          = NormalizePath(sdc[k].PropertyName);
                _compInfos[k] = new LivePropertyInfo(path, _dpFromPath.GetDP(path));
            }


            if (TestLiveShapingFlag(flags, LiveShapingFlags.Sorting))
            {
                // get the list of property paths to observe
                Collection <string> sortProperties = View.LiveSortingProperties;

                if (sortProperties.Count == 0)
                {
                    // use the sort description properties
                    _sortInfos = _compInfos;
                }
                else
                {
                    // use the explicit list of properties
                    n          = sortProperties.Count;
                    _sortInfos = new LivePropertyInfo[n];
                    for (k = 0; k < n; ++k)
                    {
                        path          = NormalizePath(sortProperties[k]);
                        _sortInfos[k] = new LivePropertyInfo(path, _dpFromPath.GetDP(path));
                    }
                }
            }
            else
            {
                _sortInfos = new LivePropertyInfo[0];
            }


            // Filtering //

            if (TestLiveShapingFlag(flags, LiveShapingFlags.Filtering))
            {
                // get the list of property paths to observe
                Collection <string> filterProperties = View.LiveFilteringProperties;
                n            = filterProperties.Count;
                _filterInfos = new LivePropertyInfo[n];
                for (k = 0; k < n; ++k)
                {
                    path            = NormalizePath(filterProperties[k]);
                    _filterInfos[k] = new LivePropertyInfo(path, _dpFromPath.GetDP(path));
                }

                _filterRoot = new LiveShapingTree(this);
            }
            else
            {
                _filterInfos = new LivePropertyInfo[0];
                _filterRoot  = null;
            }


            // Grouping //

            if (TestLiveShapingFlag(flags, LiveShapingFlags.Grouping))
            {
                // get the list of property paths to observe
                Collection <string> groupingProperties = View.LiveGroupingProperties;

                if (groupingProperties.Count == 0)
                {
                    // if no explicit list, use the group description properties
                    groupingProperties = new Collection <string>();
                    ICollectionView icv = View as ICollectionView;
                    ObservableCollection <GroupDescription> groupDescriptions = (icv != null) ? icv.GroupDescriptions : null;

                    if (groupDescriptions != null)
                    {
                        foreach (GroupDescription gd in groupDescriptions)
                        {
                            PropertyGroupDescription pgd = gd as PropertyGroupDescription;
                            if (pgd != null)
                            {
                                groupingProperties.Add(pgd.PropertyName);
                            }
                        }
                    }
                }

                n           = groupingProperties.Count;
                _groupInfos = new LivePropertyInfo[n];
                for (k = 0; k < n; ++k)
                {
                    path           = NormalizePath(groupingProperties[k]);
                    _groupInfos[k] = new LivePropertyInfo(path, _dpFromPath.GetDP(path));
                }
            }
            else
            {
                _groupInfos = new LivePropertyInfo[0];
            }

            _dpFromPath.EndReset();
        }