示例#1
0
        public static IObservable <CollectionAddEvent <T> > OnAdd <T>(this IEnumerable <T> collection)
        {
            var previousCollection = new List <T>();

            return(Observable.EveryUpdate().SelectMany(_ =>
            {
                var changedItems = collection.Where(item => !previousCollection.Contains(item)).ToList();

                var index = 0;
                var events = changedItems.Select(item =>
                {
                    var evt = new CollectionAddEvent <T>(index, item);
                    index += 1;
                    return evt;
                });

                previousCollection = collection.ToList();
                return events;
            }));
        }
 public bool Equals(CollectionAddEvent <T> other)
 {
     return(Index.Equals(other.Index) && EqualityComparer <T> .Default.Equals(Value, other.Value));
 }