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

            myStorage.RemoveAt(index);
            myChange.Fire(ListEvent <T> .Remove(index, old));
        }
Example #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));
 }
Example #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));
        }
Example #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);
 }
Example #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));
            }
        }