예제 #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();
                    }
                }
            }
예제 #3
0
        private static IEnumerable <CollectionOperation <T> > Enumerate([NotNull] ICollectionResetOperation <T> reset)
        {
            yield return(CollectionOperation <T> .OnClear());

            if (reset.Items != null)
            {
                foreach (var item in reset.Items)
                {
                    yield return(CollectionOperation <T> .OnAdd(item));
                }
            }
        }