private void unregisterSourceItem(int sourceIndex) { OrderingItemInfo <TOrderingValue> itemInfo = _itemInfos[sourceIndex]; Utils.disposeExpressionWatcher(itemInfo.ExpressionWatcher, itemInfo.NestedComputings, this, _orderingValueSelectorContainsParametrizedLiveLinqCalls); int orderedIndex = itemInfo.OrderedItemInfo.Index; _orderedPositions.Remove(orderedIndex); _sourcePositions.Remove(sourceIndex); _orderingValues.RemoveAt(orderedIndex); if (_thenOrderingsCount > 0) { RangePosition rangePosition = itemInfo.OrderedItemInfo.RangePosition; if (rangePosition.Length == 1) { _equalOrderingValueRangePositions.Remove(rangePosition.Index); } else { _equalOrderingValueRangePositions.ModifyLength(rangePosition.Index, -1); } } baseRemoveItem(orderedIndex); }
void ISourceCollectionChangeProcessor.processSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: int newIndex = e.NewStartingIndex; TSourceItem addedItem = (TSourceItem)e.NewItems[0]; registerSourceItem(addedItem, newIndex); break; case NotifyCollectionChangedAction.Remove: unregisterSourceItem(e.OldStartingIndex); break; case NotifyCollectionChangedAction.Replace: int replacingSourceIndex = e.NewStartingIndex; TSourceItem replacingSourceItem = (TSourceItem)e.NewItems[0]; OrderingItemInfo <TOrderingValue> replacingItemInfo = _itemInfos[replacingSourceIndex]; ExpressionWatcher oldExpressionWatcher = replacingItemInfo.ExpressionWatcher; Utils.disposeExpressionWatcher(oldExpressionWatcher, replacingItemInfo.NestedComputings, this, _orderingValueSelectorContainsParametrizedLiveLinqCalls); Utils.getItemInfoContent( new object[] { replacingSourceItem }, out ExpressionWatcher newExpressionWatcher, out Func <TOrderingValue> newGetOrderingValueFunc, out List <IComputingInternal> nestedComputings, _orderingValueSelectorExpression, out _orderingValueSelectorExpressionCallCount, this, _orderingValueSelectorContainsParametrizedLiveLinqCalls, _orderingValueSelectorExpressionInfo); replacingItemInfo.GetOrderingValueFunc = newGetOrderingValueFunc; replacingItemInfo.ExpressionWatcher = newExpressionWatcher; replacingItemInfo.ExpressionWatcher.ValueChanged = expressionWatcher_OnValueChanged; newExpressionWatcher._position = oldExpressionWatcher._position; replacingItemInfo.NestedComputings = nestedComputings; baseSetItem(replacingItemInfo.OrderedItemInfo.Index, replacingSourceItem); processSourceItemChange(replacingSourceIndex, replacingSourceItem); break; case NotifyCollectionChangedAction.Move: int oldStartingIndex = e.OldStartingIndex; int newStartingIndex = e.NewStartingIndex; if (oldStartingIndex != newStartingIndex) { _sourcePositions.Move(oldStartingIndex, newStartingIndex); } break; case NotifyCollectionChangedAction.Reset: processSource(); break; } }
private void unregisterSourceItem(int sourceIndex) { ItemInfo itemInfo = _itemInfos[sourceIndex]; Utils.disposeExpressionWatcher(itemInfo.ExpressionWatcher, itemInfo.NestedComputings, this, _predicateContainsParametrizedObservableComputationCalls); _sourcePositions.Remove(sourceIndex); }
private void unregisterSourceItem(int index, bool replacing = false) { Utils.disposeExpressionWatcher(_itemInfos[index].ExpressionWatcher, _itemInfos[index].NestedComputings, this, _selectorContainsParametrizedObservableComputationsCalls); if (!replacing) { _sourcePositions.Remove(index); } }
internal static bool ProcessReplaceSourceItem <TExpression, TSourceItem>( FilteringItemInfo replacingItemInfo, TSourceItem sourceItem, object[] sourceItems, int sourceIndex, bool predicateContainsParametrizedObservableComputationsCalls, Expression <TExpression> predicateExpression, out int predicateExpressionCallCount, ExpressionWatcher.ExpressionInfo orderingValueSelectorExpressionInfo, List <FilteringItemInfo> filteringItemInfos, Positions <Position> filteredPositions, IFiltering <TSourceItem> thisAsFiltering, CollectionComputing <TSourceItem> current) { ExpressionWatcher oldExpressionWatcher = replacingItemInfo.ExpressionWatcher; Utils.disposeExpressionWatcher(oldExpressionWatcher, replacingItemInfo.NestedComputings, thisAsFiltering, predicateContainsParametrizedObservableComputationsCalls); Utils.getItemInfoContent( sourceItems, out ExpressionWatcher watcher, out Func <bool> predicateFunc, out List <IComputingInternal> nestedComputings1, predicateExpression, out predicateExpressionCallCount, thisAsFiltering, predicateContainsParametrizedObservableComputationsCalls, orderingValueSelectorExpressionInfo); replacingItemInfo.PredicateFunc = predicateFunc; watcher.ValueChanged = thisAsFiltering.expressionWatcher_OnValueChanged; watcher._position = oldExpressionWatcher._position; replacingItemInfo.ExpressionWatcher = watcher; replacingItemInfo.NestedComputings = nestedComputings1; bool replace = !ProcessChangeSourceItem(sourceIndex, sourceItem, filteringItemInfos, thisAsFiltering, filteredPositions, current) && replacingItemInfo.FilteredPosition != null; return(replace); }
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); } }
void ISourceCollectionChangeProcessor.processSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: int newSourceIndex = e.NewStartingIndex; TSourceItem addedSourceItem = (TSourceItem)e.NewItems[0]; ItemInfo itemInfo = registerSourceItem(addedSourceItem, newSourceIndex); if (applyPredicate(addedSourceItem, itemInfo.PredicateFunc)) { _predicatePassedCount++; itemInfo.PredicateResult = true; } calculateValue(); break; case NotifyCollectionChangedAction.Remove: int oldStartingIndex = e.OldStartingIndex; if (_itemInfos[oldStartingIndex].PredicateResult) { _predicatePassedCount--; } unregisterSourceItem(oldStartingIndex); calculateValue(); break; case NotifyCollectionChangedAction.Move: int newSourceIndex1 = e.NewStartingIndex; int oldSourceIndex = e.OldStartingIndex; if (newSourceIndex1 != oldSourceIndex) { _sourcePositions.Move(oldSourceIndex, newSourceIndex1); } break; case NotifyCollectionChangedAction.Reset: initializeFromSource(); break; case NotifyCollectionChangedAction.Replace: int newStartingIndex = e.NewStartingIndex; ItemInfo replacingItemInfo = _itemInfos[newStartingIndex]; ExpressionWatcher oldExpressionWatcher = replacingItemInfo.ExpressionWatcher; Utils.disposeExpressionWatcher(oldExpressionWatcher, replacingItemInfo.NestedComputings, this, _predicateContainsParametrizedObservableComputationCalls); if (replacingItemInfo.PredicateResult) { _predicatePassedCount--; } ExpressionWatcher watcher; Func <bool> predicateFunc; TSourceItem replacingSourceItem = (TSourceItem)e.NewItems[0]; Utils.getItemInfoContent( new object[] { replacingSourceItem }, out watcher, out predicateFunc, out List <IComputingInternal> nestedComputings1, _predicateExpression, out _predicateExpressionСallCount, this, _predicateContainsParametrizedObservableComputationCalls, _predicateExpressionInfo); replacingItemInfo.PredicateFunc = predicateFunc; watcher.ValueChanged = expressionWatcher_OnValueChanged; watcher._position = oldExpressionWatcher._position; replacingItemInfo.ExpressionWatcher = watcher; replacingItemInfo.NestedComputings = nestedComputings1; if (applyPredicate(replacingSourceItem, predicateFunc)) { _predicatePassedCount++; replacingItemInfo.PredicateResult = true; } else { replacingItemInfo.PredicateResult = false; } calculateValue(); break; } }