Ejemplo n.º 1
0
        internal static bool ProcessChangeSourceItem <TSourceItem>(int sourceIndex,
                                                                   TSourceItem sourceItem,
                                                                   List <FilteringItemInfo> filteringItemInfos,
                                                                   IFiltering <TSourceItem> filtering,
                                                                   Positions <Position> filteredPositions,
                                                                   CollectionComputing <TSourceItem> current,
                                                                   ExpressionWatcher expressionWatcher)
        {
            if (expressionWatcher._disposed)
            {
                return(false);
            }

            FilteringItemInfo itemInfo = filteringItemInfos[sourceIndex];

            bool newPredicateValue = filtering.applyPredicate(sourceItem, itemInfo.PredicateFunc);
            bool oldPredicateValue = itemInfo.FilteredPosition != null;

            if (newPredicateValue != oldPredicateValue)
            {
                if (newPredicateValue)
                {
                    int newIndex = itemInfo.NextFilteredItemPosition.Index;
                    itemInfo.FilteredPosition = filteredPositions.Insert(newIndex);
                    newIndex = itemInfo.FilteredPosition.Index;
                    modifyNextFilteredItemIndex(sourceIndex, itemInfo.FilteredPosition, filteringItemInfos);
                    current.baseInsertItem(newIndex, sourceItem);
                    return(true);
                }
                else // if (oldPredicaeValue)
                {
                    int index = itemInfo.FilteredPosition.Index;
                    filteredPositions.Remove(index);
                    itemInfo.FilteredPosition = null;
                    modifyNextFilteredItemIndex(sourceIndex, itemInfo.NextFilteredItemPosition, filteringItemInfos);
                    current.baseRemoveItem(index);
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        internal static void ProcessMoveSourceItems <TSourceItem1>(int oldSourceIndex, int newSourceIndex1,
                                                                   List <FilteringItemInfo> filteringItemInfos, Positions <Position> filteredPositions,
                                                                   Positions <FilteringItemInfo> sourcePositions, CollectionComputing <TSourceItem1> current)
        {
            if (newSourceIndex1 != oldSourceIndex)
            {
                FilteringItemInfo itemInfoOfOldSourceIndex = filteringItemInfos[oldSourceIndex];
                FilteringItemInfo itemInfoOfNewSourceIndex = filteringItemInfos[newSourceIndex1];

                Position nextPosition1;

                Position itemInfoOfOldSourceIndexFilteredPosition         = itemInfoOfOldSourceIndex.FilteredPosition;
                Position itemInfoOfNewSourceIndexNextFilteredItemPosition = itemInfoOfNewSourceIndex.NextFilteredItemPosition;
                Position itemInfoOfNewSourceIndexFilteredPosition         = itemInfoOfNewSourceIndex.FilteredPosition;
                if (itemInfoOfOldSourceIndexFilteredPosition != null)
                {
                    int oldFilteredIndex = itemInfoOfOldSourceIndexFilteredPosition.Index;
                    int newFilteredIndex1;

                    Position newPosition1 = itemInfoOfOldSourceIndexFilteredPosition;
                    if (itemInfoOfNewSourceIndexFilteredPosition == null)
                    {
                        //nextPositionIndex = itemInfoOfNewSourceIndex.NextFilteredItemIndex;
                        nextPosition1 =
                            itemInfoOfNewSourceIndexNextFilteredItemPosition != itemInfoOfOldSourceIndexFilteredPosition
                                                                ? itemInfoOfNewSourceIndexNextFilteredItemPosition
                                                                : itemInfoOfOldSourceIndex.NextFilteredItemPosition;
                        newFilteredIndex1 = oldSourceIndex < newSourceIndex1
                                                        ? itemInfoOfNewSourceIndexNextFilteredItemPosition.Index - 1
                                                        : itemInfoOfNewSourceIndexNextFilteredItemPosition.Index;
                    }
                    else
                    {
                        nextPosition1 = oldSourceIndex < newSourceIndex1
                                                        ? itemInfoOfNewSourceIndexNextFilteredItemPosition
                                                        : itemInfoOfNewSourceIndexFilteredPosition;
                        newFilteredIndex1 = itemInfoOfNewSourceIndexFilteredPosition.Index;
                    }

                    filteredPositions.Move(
                        oldFilteredIndex,
                        newFilteredIndex1);

                    modifyNextFilteredItemIndex(oldSourceIndex,
                                                itemInfoOfOldSourceIndex.NextFilteredItemPosition, filteringItemInfos);

                    sourcePositions.Move(oldSourceIndex, newSourceIndex1);

                    itemInfoOfOldSourceIndex.NextFilteredItemPosition = nextPosition1;

                    modifyNextFilteredItemIndex(newSourceIndex1, newPosition1, filteringItemInfos);

                    current.baseMoveItem(oldFilteredIndex, newFilteredIndex1);
                }
                else
                {
                    nextPosition1 = oldSourceIndex < newSourceIndex1
                                                ? itemInfoOfNewSourceIndexNextFilteredItemPosition
                                                : (itemInfoOfNewSourceIndexFilteredPosition ?? itemInfoOfNewSourceIndexNextFilteredItemPosition);

                    itemInfoOfOldSourceIndex.NextFilteredItemPosition = nextPosition1;

                    sourcePositions.Move(oldSourceIndex, newSourceIndex1);
                }
            }
        }