コード例 #1
0
                protected override IEnumerable <CollectionOperation <TAdaptee> > Enumerate()
                {
                    foreach (var update in _adaptee.Operations())
                    {
                        switch (update.Type)
                        {
                        case CollectionOperationType.Add:
                            var added = _state.Get(update.Item, _removedOnChange);
                            yield return(CollectionOperation <TAdaptee> .OnAdd(added));

                            break;

                        case CollectionOperationType.Remove:
                            var removed = _state.Get(update.Item, _removedOnChange);
                            yield return(CollectionOperation <TAdaptee> .OnRemove(removed));

                            break;

                        case CollectionOperationType.Clear:
                            yield return(CollectionOperation <TAdaptee> .OnClear());

                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                }
コード例 #2
0
            protected override IEnumerable <ListOperation <TAdaptee> > Enumerate()
            {
                foreach (var update in _adaptee.Operations())
                {
                    switch (update.Type)
                    {
                    case ListOperationType.Add:
                        yield return(ListOperation <TAdaptee> .OnAdd(
                                         _state.Get(update.Item, _removed),
                                         update.Index));

                        break;

                    case ListOperationType.Remove:
                        yield return(ListOperation <TAdaptee> .OnRemove(
                                         _state.Get(update.Item, _removed),
                                         update.Index));

                        break;

                    case ListOperationType.Move:
                        yield return(ListOperation <TAdaptee> .OnMove(
                                         _state.Get(update.Item, _removed),
                                         update.Index,
                                         update.OriginalIndex));

                        break;

                    case ListOperationType.Replace:
                        yield return(ListOperation <TAdaptee> .OnReplace(
                                         _state.Get(update.Item, _removed),
                                         _state.Get(update.ChangedItem, _removed),
                                         update.Index));

                        break;

                    case ListOperationType.Clear:
                        yield return(ListOperation <TAdaptee> .OnClear());

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }