Exemplo n.º 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();
                        }
                    }
                }
            public IEnumerable <CollectionOperation <TAdaptee> > Operations()
            {
                foreach (var u in _adaptee.Operations())
                {
                    switch (u.Type)
                    {
                    case CollectionOperationType.Add:
                        yield return(CollectionOperation <TAdaptee> .OnAdd(_selector(u.Item)));

                        break;

                    case CollectionOperationType.Remove:
                        yield return(CollectionOperation <TAdaptee> .OnRemove(_selector(u.Item)));

                        break;

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

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
Exemplo n.º 3
0
        private static IEnumerable <CollectionOperation <T> > Enumerate([NotNull] ICollectionReplaceOperation <T> replace)
        {
            yield return(CollectionOperation <T> .OnRemove(replace.ReplacedItem));

            yield return(CollectionOperation <T> .OnAdd(replace.Item));
        }
Exemplo n.º 4
0
 private static ItemOrEnumerable <CollectionOperation <T> > OnRemove([NotNull] ICollectionRemoveOperation <T> remove) =>
 new ItemOrEnumerable <CollectionOperation <T> >(CollectionOperation <T> .OnRemove(remove.Item));