Example #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());
        }
Example #2
0
        private void UpdateItemMembership(T item, List <ReferenceCountTracker <T> > sourceLists, ChangeAwareListWithRefCounts <T> resultList)
        {
            var isInResult       = resultList.Contains(item);
            var shouldBeInResult = MatchesConstraint(sourceLists, item);

            if (shouldBeInResult && !isInResult)
            {
                resultList.Add(item);
            }
            else if (!shouldBeInResult && isInResult)
            {
                resultList.Remove(item);
            }
        }
Example #3
0
        private void ProcessItem(MergeContainer[] sourceLists, ChangeAwareListWithRefCounts <T> resultingList, T item)
        {
            //check whether the item should be removed from the list
            var isInResult       = resultingList.Contains(item);
            var shouldBeInResult = MatchesConstraint(sourceLists, item);

            if (shouldBeInResult)
            {
                if (!isInResult)
                {
                    resultingList.Add(item);
                }
            }
            else
            {
                if (isInResult)
                {
                    resultingList.Remove(item);
                }
            }
        }