Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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());
        }
Esempio n. 3
0
 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());
 }
Esempio n. 4
0
 private IChangeSet <T> ProcessChanges(MergeContainer[] sourceLists, ChangeAwareListWithRefCounts <T> resultingList, IEnumerable <T> items)
 {
     //check whether the item should be removed from the list
     items.ForEach(item => { ProcessItem(sourceLists, resultingList, item); });
     return(resultingList.CaptureChanges());
 }
 private IChangeSet <T> UpdateItemSetMemberships(MergeContainer[] sourceLists, ChangeAwareListWithRefCounts <T> resultingList, IEnumerable <T> items)
 {
     items.ForEach(item => UpdateItemMembership(item, sourceLists, resultingList));
     return(resultingList.CaptureChanges());
 }