Ejemplo n.º 1
0
            public void Accept(INotifyCollectionChanged collection)
            {
                int collectionId = this.idProvider[collection];

                int index = 0;

                foreach (object item in GetIncludedItems(collection))
                {
                    this.changes.Add(CollectionItemAdded.Create(collectionId, item, idProvider, index++));
                }
            }
Ejemplo n.º 2
0
        private void collectionChanged(object sender_, NotifyCollectionChangedEventArgs e)
        {
            if (!(sender_ is INotifyCollectionChanged))
            {
                throw new ArgumentException();
            }
            INotifyCollectionChanged sender = (INotifyCollectionChanged)sender_;
            int senderId = 0;

            Change change;

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                if (e.NewItems.Count != 0)
                {
                    throw new NotImplementedException();
                }
                Contract.Requires(e.NewStartingIndex >= 0, "The index of the added item(s) must be specified");
                change = CollectionItemAdded.Create(senderId, e.NewItems[0], e.NewStartingIndex == -1 ? default(int?) : e.NewStartingIndex);
                if (IncludeDeep(sender, item: e.NewItems[0]))
                {
                    registerViewmodelAndAddCompleteStateAsChanges(e.NewItems[0]);
                }
                break;

            case NotifyCollectionChangedAction.Move:
                throw new NotImplementedException();

            case NotifyCollectionChangedAction.Remove:
                Contract.Requires(e.OldStartingIndex >= 0, "The index of the removed item must be specified");
                change = CollectionItemRemoved.Create(senderId, e.OldStartingIndex);
                break;

            case NotifyCollectionChangedAction.Replace:
                throw new NotImplementedException();

            case NotifyCollectionChangedAction.Reset:
                throw new NotImplementedException();

            default:
                throw new ArgumentException("Invalid action", nameof(e));
            }

            this.AddChange(change);
        }