protected bool ModifyIf(Func <bool> action, Func <ListEventArgs> fargs) { if (!this.ContainsListeners) { return(action()); } ListEventArgs args = fargs(); if (!action()) { return(false); } if (!args.IsEmpty) { this.OnListChanged(args); } return(true); }
public sealed override void Clear() { this.Modify( () => this.ClearImpl(), () => ListEventArgs.NewEventClear(this)); }
public sealed override void RemoveAt(int index) { this.Modify( () => this.RemoveAtImpl(index), () => ListEventArgs.NewEventRemoveRange(new[] { index }, new[] { this[index] })); }
public sealed override void Insert(int index, T item) { this.Modify( () => this.InsertImpl(index, item), () => ListEventArgs.NewEventAddRange(new[] { index }, new[] { item })); }
public sealed override void RemoveAll(IEnumerable <T> enumer) { this.Modify( () => this.RemoveAllImpl(enumer), () => ListEventArgs.NewEventRemoveRange(enumer.Select(this.IndexOf), enumer)); }
public sealed override void AddAll(IEnumerable <T> enumer) { this.Modify( () => this.InsertAllImpl(this.Count, enumer), () => ListEventArgs.NewEventAddRange(this.Count, enumer)); }
public sealed override void RemoveAll(int index, int count) { this.Modify( () => this.RemoveAllImpl(index, count), () => ListEventArgs.NewEventRemoveRange(index, Enumerable.Range(index, count).Select(i => this[i]))); }
public sealed override void InsertAll(int index, IEnumerable <T> enumer) { this.Modify( () => this.InsertAllImpl(index, enumer), () => ListEventArgs.NewEventAddRange(index, enumer)); }