private void LocationCollection_CollectionChanged()

in src/Sarif.Viewer.VisualStudio.Core/Models/LocationCollection.cs [28:57]


        private void LocationCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                if (e.NewItems != null)
                {
                    foreach (object newItem in e.NewItems)
                    {
                        if (newItem is INotifyPropertyChanged notifyPropertyChanged)
                        {
                            notifyPropertyChanged.PropertyChanged += this.LocationModelPropertyChanged;
                        }
                    }
                }
            }

            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                if (e.OldItems != null)
                {
                    foreach (object oldItem in e.OldItems)
                    {
                        if (oldItem is INotifyPropertyChanged notifyPropertyChanged)
                        {
                            notifyPropertyChanged.PropertyChanged -= this.LocationModelPropertyChanged;
                        }
                    }
                }
            }
        }