Esempio n. 1
0
        void setupCollection(IScheduler sched)
        {
            ChangeTrackingEnabled = true;
            _sched = sched ?? RxApp.DeferredScheduler;
            invalidateHash();

            ItemsAdded.Subscribe(x => {
                if (ChangeTrackingEnabled == false) {
                    return;
                }
                CreatedOn[x.ContentHash] = _sched.Now;
                UpdatedOn[x.ContentHash] = _sched.Now;
            });

            ItemsRemoved.Subscribe(x => {
                if (ChangeTrackingEnabled == false) {
                    return;
                }
                CreatedOn.Remove(x.ContentHash);
                UpdatedOn.Remove(x.ContentHash);
            });

            ItemChanged.Subscribe(x => {
                if (ChangeTrackingEnabled == false) {
                    return;
                }
                UpdatedOn[x.Sender.ContentHash] = _sched.Now;
            });

            Changed.Subscribe(_ => invalidateHash());
        }
Esempio n. 2
0
 private void Initialize()
 {
     ItemsAdded.Subscribe(x =>
     {
         _toInsert.Add(x);
         //Dump();
     });
     ItemsRemoved.Subscribe(x =>
     {
         if (x.IsNew)
         {
             _toInsert.Remove(x);
             //Dump();
         }
         else
         {
             _toUpdate.Remove(x);
             _toDelete.Add(x);
             // Dump();
         }
     });
     ItemChanged.Subscribe(x =>
     {
         if (!x.Sender.IsNew)
         {
             _toUpdate.Add(x.Sender);
             // Dump();
         }
     });
 }