private IChangeSet <T> UpdateResultList(IChangeSet <T> changes, List <ReferenceCountTracker <T> > sourceLists, ChangeAwareListWithRefCounts <T> resultList) { //child caches have been updated before we reached this point. foreach (var change in changes.Flatten()) { var item = change.Current; var isInResult = resultList.Contains(item); var shouldBeInResult = MatchesConstraint(sourceLists, item); if (shouldBeInResult) { if (!isInResult) { resultList.Add(item); } else if (change.Reason == ListChangeReason.Refresh) { resultList.Refresh(change.Current); } } else { if (isInResult) { resultList.Remove(item); } } } return(resultList.CaptureChanges()); }
private IChangeSet <T> UpdateResultList(IChangeSet <T> changes) { //child caches have been updated before we reached this point. changes.Flatten().ForEach(change => { var item = change.Current; var isInResult = _resultList.Contains(item); var shouldBeInResult = MatchesConstraint(item); if (shouldBeInResult) { if (!isInResult) { _resultList.Add(item); } } else { if (isInResult) { _resultList.Remove(item); } } }); return(_resultList.CaptureChanges()); }
private IChangeSet <T> UpdateResultList(IChangeSet <T> changes, List <ReferenceCountTracker <T> > sourceLists, ChangeAwareListWithRefCounts <T> resultList) { //child caches have been updated before we reached this point. foreach (var change in changes.Flatten()) { switch (change.Reason) { case ListChangeReason.Add: case ListChangeReason.Remove: UpdateItemMembership(change.Current, sourceLists, resultList); break; case ListChangeReason.Replace: UpdateItemMembership(change.Previous.Value, sourceLists, resultList); UpdateItemMembership(change.Current, sourceLists, resultList); break; // Pass through refresh changes: case ListChangeReason.Refresh: resultList.Refresh(change.Current); break; // A move does not affect contents and so can be ignored: case ListChangeReason.Moved: break; // These should not occur as they are replaced by the Flatten operator: //case ListChangeReason.AddRange: //case ListChangeReason.RemoveRange: //case ListChangeReason.Clear: default: throw new ArgumentOutOfRangeException(nameof(change.Reason), "Unsupported change type"); } } return(resultList.CaptureChanges()); }
private IChangeSet <T> UpdateResultList(MergeContainer[] sourceLists, ChangeAwareListWithRefCounts <T> resultingList, IChangeSet <T> changes) { //child caches have been updated before we reached this point. changes.Flatten().ForEach(change => { ProcessItem(sourceLists, resultingList, change.Current); }); return(resultingList.CaptureChanges()); }