예제 #1
0
        public void RemoveAt(int index)
        {
            var old = myStorage[index];

            myStorage.RemoveAt(index);
            myChange.Fire(ListEvent <T> .Remove(index, old));
        }
예제 #2
0
 // 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));
 }
예제 #3
0
        // 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));
        }
예제 #4
0
 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);
 }
예제 #5
0
        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));
            }
        }