Example #1
0
        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);
        }
Example #2
0
 public sealed override void Clear()
 {
     this.Modify(
         () => this.ClearImpl(),
         () => ListEventArgs.NewEventClear(this));
 }
Example #3
0
 public sealed override void RemoveAt(int index)
 {
     this.Modify(
         () => this.RemoveAtImpl(index),
         () => ListEventArgs.NewEventRemoveRange(new[] { index }, new[] { this[index] }));
 }
Example #4
0
 public sealed override void Insert(int index, T item)
 {
     this.Modify(
         () => this.InsertImpl(index, item),
         () => ListEventArgs.NewEventAddRange(new[] { index }, new[] { item }));
 }
Example #5
0
 public sealed override void RemoveAll(IEnumerable <T> enumer)
 {
     this.Modify(
         () => this.RemoveAllImpl(enumer),
         () => ListEventArgs.NewEventRemoveRange(enumer.Select(this.IndexOf), enumer));
 }
Example #6
0
 public sealed override void AddAll(IEnumerable <T> enumer)
 {
     this.Modify(
         () => this.InsertAllImpl(this.Count, enumer),
         () => ListEventArgs.NewEventAddRange(this.Count, enumer));
 }
Example #7
0
 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])));
 }
Example #8
0
 public sealed override void InsertAll(int index, IEnumerable <T> enumer)
 {
     this.Modify(
         () => this.InsertAllImpl(index, enumer),
         () => ListEventArgs.NewEventAddRange(index, enumer));
 }