protected virtual void OnRemovingItem(CollectionChangingEventArgs e) { if (RemovingItem != null) { RemovingItem(this, e); } }
protected virtual void OnInsertingItem(CollectionChangingEventArgs e) { if (InsertingItem != null) { InsertingItem(this, e); } }
/// <inheritdoc /> public void Insert(int index, T item) { var eventArgs = new CollectionChangingEventArgs(item, index); OnInsertingItem(eventArgs); if (!eventArgs.Cancel) { _collection.Insert(index, item); OnInsertedItem(new CollectionChangedEventArgs(item, index)); } }
/// <inheritdoc /> public void RemoveAt(int index) { T item = _collection[index]; var eventArgs = new CollectionChangingEventArgs(item, index); OnRemovingItem(eventArgs); if (!eventArgs.Cancel) { _collection.RemoveAt(index); OnRemovedItem(new CollectionChangedEventArgs(item, index)); } }