protected override void initializeFromSource() { if (_sourceInitialized) { Utils.disposeExpressionItemInfos(_itemInfos, _predicateExpressionСallCount, this); Utils.RemoveDownstreamConsumedComputing(_itemInfos, this); Utils.disposeSource( _sourceScalar, _source, out _itemInfos, out _sourcePositions, _sourceAsList, handleSourceCollectionChanged); _sourceInitialized = false; } _predicatePassedCount = 0; Utils.changeSource(ref _source, _sourceScalar, _downstreamConsumedComputings, _consumers, this, ref _sourceAsList, false); if (_source != null && _isActive) { Utils.initializeFromObservableCollectionWithChangeMarker( _source, ref _sourceAsList, ref _rootSourceWrapper, ref _lastProcessedSourceChangeMarker); int count = _sourceAsList.Count; for (int sourceIndex = 0; sourceIndex < count; sourceIndex++) { TSourceItem sourceItem = _sourceAsList[sourceIndex]; ItemInfo itemInfo = registerSourceItem(sourceItem, sourceIndex); if (applyPredicate(sourceItem, itemInfo.PredicateFunc)) { _predicatePassedCount++; itemInfo.PredicateResult = true; } } _sourceAsList.CollectionChanged += handleSourceCollectionChanged; calculateValue(); _sourceInitialized = true; } else { if (_value) { setValue(false); } } }
protected override void initializeFromSource() { if (_sourceInitialized) { Utils.disposeExpressionItemInfos(_itemInfos, _orderingValueSelectorExpressionСallCount, this); Utils.RemoveDownstreamConsumedComputing(_itemInfos, this); int capacity = Utils.disposeSource( _sourceScalar, _source, out _itemInfos, out _sourcePositions, _sourceAsList, handleSourceCollectionChanged); Utils.construct(capacity, out _orderedItemInfos, out _orderedPositions, out _orderingValues); _items.Clear(); _sourceInitialized = false; } Utils.changeSource(ref _source, _sourceScalar, _downstreamConsumedComputings, _consumers, this, ref _sourceAsList, false); if (_source != null && _isActive) { Utils.initializeFromObservableCollectionWithChangeMarker( _source, ref _sourceAsList, ref _rootSourceWrapper, ref _lastProcessedSourceChangeMarker); int count = _sourceAsList.Count; TSourceItem[] sourceCopy = new TSourceItem[count]; _sourceAsList.CopyTo(sourceCopy, 0); _sourceAsList.CollectionChanged += handleSourceCollectionChanged; int sourceIndex; for (sourceIndex = 0; sourceIndex < count; sourceIndex++) { registerSourceItem(sourceCopy[sourceIndex], sourceIndex, true); } _sourceInitialized = true; } reset(); }
internal override void removeFromUpstreamComputings(IComputingInternal computing) { void perform() => Utils.RemoveDownstreamConsumedComputing(computing, _sourceScalar, _source); if (_sourceOcDispatcher != null) { _sourceOcDispatcher.Invoke( perform, _sourceOcDispatcherPriority, _sourceOcDispatcherParameter, this); } else { perform(); } }
internal override void removeFromUpstreamComputings(IComputingInternal computing) { Utils.RemoveDownstreamConsumedComputing(computing, _sourceScalar, _source); }
protected override void initializeFromSource() { int originalCount = _items.Count; if (_sourceInitialized) { Utils.disposeExpressionItemInfos(_itemInfos, _selectorExpressionСallCount, this); Utils.RemoveDownstreamConsumedComputing(_itemInfos, this); Utils.disposeSource( _sourceScalar, _source, out _itemInfos, out _sourcePositions, _sourceAsList, handleSourceCollectionChanged); _sourceInitialized = false; } Utils.changeSource(ref _source, _sourceScalar, _downstreamConsumedComputings, _consumers, this, ref _sourceAsList, false); if (_source != null && _isActive) { Utils.initializeFromObservableCollectionWithChangeMarker( _source, ref _sourceAsList, ref _rootSourceWrapper, ref _lastProcessedSourceChangeMarker); int count = _sourceAsList.Count; TSourceItem[] sourceCopy = new TSourceItem[count]; _sourceAsList.CopyTo(sourceCopy, 0); _sourceAsList.CollectionChanged += handleSourceCollectionChanged; int sourceIndex; for (sourceIndex = 0; sourceIndex < count; sourceIndex++) { TSourceItem sourceItem = sourceCopy[sourceIndex]; ItemInfo itemInfo = registerSourceItem(sourceItem, sourceIndex); if (originalCount > sourceIndex) { _items[sourceIndex] = applySelector(itemInfo, sourceItem); } else { _items.Insert(sourceIndex, applySelector(itemInfo, sourceItem)); } } for (int index = originalCount - 1; index >= sourceIndex; index--) { _items.RemoveAt(index); } _sourceInitialized = true; } else { _items.Clear(); } reset(); }
internal override void removeFromUpstreamComputings(IComputingInternal computing) { (_source as IComputingInternal)?.RemoveDownstreamConsumedComputing(computing); (_sourceScalar as IComputingInternal)?.RemoveDownstreamConsumedComputing(computing); Utils.RemoveDownstreamConsumedComputing(_itemInfos, this); }
internal override void removeFromUpstreamComputings(IComputingInternal computing) { Utils.RemoveDownstreamConsumedComputing(computing, _sourceScalar, _source); (_sortDirectionScalar as IComputingInternal)?.RemoveDownstreamConsumedComputing(computing); (_comparerScalar as IComputingInternal)?.RemoveDownstreamConsumedComputing(computing); }
protected override void initializeFromSource() { int originalCount = _items.Count; if (_sourceInitialized) { Utils.disposeExpressionItemInfos(_itemInfos, _predicateExpressionСallCount, this); Utils.RemoveDownstreamConsumedComputing(_itemInfos, this); _filteredPositions = new Positions <Position>(new List <Position>(_initialCapacity)); Utils.disposeSource( _sourceScalar, _source, out _itemInfos, out _sourcePositions, _sourceAsList, handleSourceCollectionChanged); _sourceInitialized = false; } Utils.changeSource(ref _source, _sourceScalar, _downstreamConsumedComputings, _consumers, this, ref _sourceAsList, false); if (_source != null && _isActive) { Utils.initializeFromObservableCollectionWithChangeMarker( _source, ref _sourceAsList, ref _rootSourceWrapper, ref _lastProcessedSourceChangeMarker); Position nextItemPosition = _filteredPositions.Add(); int count = _sourceAsList.Count; TSourceItem[] sourceCopy = new TSourceItem[count]; _sourceAsList.CopyTo(sourceCopy, 0); _sourceAsList.CollectionChanged += handleSourceCollectionChanged; int insertingIndex = 0; int sourceIndex; for (sourceIndex = 0; sourceIndex < count; sourceIndex++) { TSourceItem sourceItem = sourceCopy[sourceIndex]; Position currentFilteredItemPosition = null; FilteringItemInfo itemInfo = registerSourceItem(sourceItem, sourceIndex, null, null); if (_thisAsFiltering.applyPredicate(sourceItem, itemInfo.PredicateFunc)) { if (originalCount > insertingIndex) { _items[insertingIndex++] = sourceItem; } else { _items.Insert(insertingIndex++, sourceItem); } currentFilteredItemPosition = nextItemPosition; nextItemPosition = _filteredPositions.Add(); } itemInfo.FilteredPosition = currentFilteredItemPosition; itemInfo.NextFilteredItemPosition = nextItemPosition; } for (int index = originalCount - 1; index >= insertingIndex; index--) { _items.RemoveAt(index); } _sourceInitialized = true; } else { _items.Clear(); } reset(); }