public void RemoveAt(int index) { var old = myStorage[index]; myStorage.RemoveAt(index); myChange.Fire(ListEvent <T> .Remove(index, old)); }
// ReSharper disable once AnnotationConflictInHierarchy public void Add([NotNull] T item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } myStorage.Add(item); myChange.Fire(ListEvent <T> .Add(myStorage.Count - 1, item)); }
// ReSharper disable once AnnotationConflictInHierarchy public void Insert(int index, [NotNull] T item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } myStorage.Insert(index, item); myChange.Fire(ListEvent <T> .Add(index, item)); }
public void Advise(Lifetime lifetime, Action <ListEvent <T> > handler) { for (int index = 0; index < myStorage.Count; index++) { try { handler(ListEvent <T> .Add(index, myStorage[index])); } catch (Exception e) { Log.Root.Error(e); } } myChange.Advise(lifetime, handler); }
public T this[int index] { get { return(myStorage[index]); } set { Assertion.Require(value != null, "value != null"); var oldval = myStorage[index]; if (Equals(oldval, value)) { return; } myStorage[index] = value; myChange.Fire(ListEvent <T> .Update(index, oldval, value)); } }