/// <inheritdoc /> protected override void InsertItem(int index, T item) { var e = new CollectionChangingEventArgs(CollectionChangeAction.Add, index, item); OnCollectionChanging(e); if (e.Cancel) { return; } LogInsert(item); base.InsertItem(index, item); }
/// <inheritdoc /> protected override void RemoveItem(int index) { var e = new CollectionChangingEventArgs(CollectionChangeAction.Remove, index, Items[index]); OnCollectionChanging(e); if (e.Cancel) { return; } LogRemove(this[index]); base.RemoveItem(index); }
/// <inheritdoc /> protected override void ClearItems() { var e = new CollectionChangingEventArgs(CollectionChangeAction.Refresh); OnCollectionChanging(e); if (e.Cancel) { return; } foreach (var item in this) { LogRemove(item); } base.ClearItems(); }
/// <summary> /// Raises the <see cref="E:CollectionChanging"/> event. /// </summary> /// <param name="e">The <see cref="CollectionChangingEventArgs"/> instance containing the event data.</param> protected virtual void OnCollectionChanging(CollectionChangingEventArgs e) { CollectionChanging?.Invoke(this, e); }