示例#1
0
 private void ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
 {
     if (this.CheckFlag(CollectionViewFlags.ShouldProcessCollectionChanged))
     {
         if (args.get_Action() == 4)
         {
             if (!this.SourceCollection.GetEnumerator().MoveNext())
             {
                 this._internalList.Clear();
             }
             this.RefreshOrDefer();
         }
         else
         {
             object item = (args.get_NewItems() != null) ? args.get_NewItems()[0] : null;
             object removedItem = (args.get_OldItems() != null) ? args.get_OldItems()[0] : null;
             if ((args.get_Action() == 1) || (args.get_Action() == 2))
             {
                 this.ProcessRemoveEvent(removedItem, args.get_Action() == 2);
             }
             if (((args.get_Action() == null) || (args.get_Action() == 2)) && ((this.Filter == null) || this.PassesFilter(item)))
             {
                 this.ProcessAddEvent(item, args.get_NewStartingIndex());
             }
             if (args.get_Action() != 2)
             {
                 this.OnPropertyChanged("ItemCount");
             }
         }
     }
 }
示例#2
0
 private void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
 {
     if (args == null)
     {
         throw new ArgumentNullException("args");
     }
     this._timestamp++;
     if ((this.CollectionChanged != null) && (((args.get_Action() != null) || (this.PageSize == 0)) || (args.get_NewStartingIndex() < this.Count)))
     {
         this.CollectionChanged.Invoke(this, args);
     }
     if (args.get_Action() != 2)
     {
         this.OnPropertyChanged("Count");
     }
     bool isEmpty = this.IsEmpty;
     if (isEmpty != this.CheckFlag(CollectionViewFlags.CachedIsEmpty))
     {
         this.SetFlag(CollectionViewFlags.CachedIsEmpty, isEmpty);
         this.OnPropertyChanged("IsEmpty");
     }
 }