void ISourceItemChangeProcessor.ProcessSourceItemChange(ExpressionWatcher expressionWatcher)
        {
            int index = expressionWatcher._position.Index;

            FilteringUtils.ProcessChangeSourceItem(index, _sourceAsList[index], _itemInfos, this,
                                                   _filteredPositions, this);
        }
예제 #2
0
        private void unregisterSourceItem(int sourceIndex)
        {
            int?removeIndex            = null;
            FilteringItemInfo itemInfo = _itemInfos[sourceIndex];

            Utils.disposeExpressionWatcher(itemInfo.ExpressionWatcher, itemInfo.NestedComputings, this,
                                           _predicateContainsParametrizedObservableComputationsCalls);

            Position itemInfoFilteredPosition = itemInfo.FilteredPosition;

            if (itemInfoFilteredPosition != null)
            {
                removeIndex = itemInfoFilteredPosition.Index;
                _filteredPositions.Remove(itemInfoFilteredPosition.Index);
                FilteringUtils.modifyNextFilteredItemIndex(sourceIndex, itemInfo.NextFilteredItemPosition, _itemInfos);
            }

            _sourcePositions.Remove(sourceIndex);

            if (removeIndex.HasValue)
            {
                baseRemoveItem(removeIndex.Value);
            }
        }
예제 #3
0
        void ISourceCollectionChangeProcessor.processSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                int         newSourceIndex  = e.NewStartingIndex;
                TSourceItem addedSourceItem = (TSourceItem)e.NewItems[0];
                Position    newItemPosition = null;
                Position    nextItemPosition;

                int?newFilteredIndex = null;

                Utils.getItemInfoContent(
                    new object[] { addedSourceItem },
                    out ExpressionWatcher newWatcher,
                    out Func <bool> newPredicateFunc,
                    out List <IComputingInternal> nestedComputings,
                    _predicateExpression,
                    out _predicateExpressionCallCount,
                    this,
                    _predicateContainsParametrizedObservableComputationsCalls,
                    _predicateExpressionInfo);

                bool predicateValue = _thisAsFiltering.applyPredicate(addedSourceItem, newPredicateFunc);
                nextItemPosition = FilteringUtils.processAddSourceItem(newSourceIndex, predicateValue, ref newItemPosition,
                                                                       ref newFilteredIndex, _itemInfos, _filteredPositions, Count);

                registerSourceItem(addedSourceItem, newSourceIndex, newItemPosition, nextItemPosition, newWatcher,
                                   newPredicateFunc, nestedComputings);

                if (newFilteredIndex != null)
                {
                    baseInsertItem(newFilteredIndex.Value, addedSourceItem);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                unregisterSourceItem(e.OldStartingIndex);
                break;

            case NotifyCollectionChangedAction.Move:
                FilteringUtils.ProcessMoveSourceItems(e.OldStartingIndex, e.NewStartingIndex, _itemInfos,
                                                      _filteredPositions, _sourcePositions, this);
                break;

            case NotifyCollectionChangedAction.Reset:
                processSource();
                break;

            case NotifyCollectionChangedAction.Replace:
                int         sourceIndex         = e.NewStartingIndex;
                TSourceItem replacingSourceItem = (TSourceItem)e.NewItems[0];

                FilteringItemInfo replacingItemInfo = _itemInfos[sourceIndex];
                bool replace = FilteringUtils.ProcessReplaceSourceItem(replacingItemInfo, replacingSourceItem,
                                                                       new object[] { replacingSourceItem },
                                                                       sourceIndex, _predicateContainsParametrizedObservableComputationsCalls, _predicateExpression,
                                                                       out _predicateExpressionCallCount, _predicateExpressionInfo, _itemInfos, _filteredPositions,
                                                                       _thisAsFiltering, this);

                if (replace)
                {
                    baseSetItem(replacingItemInfo.FilteredPosition.Index, replacingSourceItem);
                }
                break;
            }
        }