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