System.Windows.Data.DataList.OnSourceCollectionChanged C# (CSharp) Method

OnSourceCollectionChanged() private method

private OnSourceCollectionChanged ( object sender, NotifyCollectionChangedEventArgs e ) : void
sender object
e System.Collections.Specialized.NotifyCollectionChangedEventArgs
return void
        private void OnSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (_ignoreChanges) {
                return;
            }

            UpdateVersion();
            if ((_snapShot == null) &&
                (_propChangedHandler == null) && (_collectionChangedHandler == null)) {
                // The snapshot hasn't been created, and there are no change notification
                // handlers, so there is no more work to be done.
                return;
            }

            switch (e.Action) {
                case NotifyCollectionChangedAction.Add:
                    if ((_predicate == null) || _predicate.Filter(e.NewItems[0])) {
                        if (_snapShot != null) {
                            AddItem(e.NewItems[0], /* notifyPropertyChange */ true);
                        }
                        else {
                            RaiseCollectionChanged(NotifyCollectionChangedAction.Add, e.NewItems[0], 0);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Remove:
                    if ((_predicate == null) || _predicate.Filter(e.OldItems[0])) {
                        if (_snapShot != null) {
                            RemoveItem(e.OldItems[0], /* notifyPropertyChange */ true);
                        }
                        else {
                            RaiseCollectionChanged(NotifyCollectionChangedAction.Remove, e.OldItems[0], 0);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Replace:
                    OnSourceCollectionChanged(sender, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, e.OldItems[0], e.OldStartingIndex));
                    OnSourceCollectionChanged(sender, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, e.NewItems[0], e.NewStartingIndex));
                    break;
                case NotifyCollectionChangedAction.Reset:
                    _snapShot = null;
                    _currentIndex = -1;
                    RaiseCollectionReset();
                    break;
            }

            if (e.Action != NotifyCollectionChangedAction.Replace) {
                RaisePropertyChanged("Count");
            }
        }