Ejemplo n.º 1
0
        public INotificationResult AggregateChanges()
        {
            INotificationResult result;

            if (!HasChanges())
            {
                result = UnchangedNotificationResult.Instance;
            }
            else if (isReset)
            {
                result = new CollectionChangedNotificationResult <T>(null);
            }
            else
            {
                result = new CollectionChangedNotificationResult <T>
                         (
                    null,
                    addedItems,
                    removedItems,
                    movedItems,
                    replaceAddedItems,
                    replaceRemovedItems
                         );
            }

            engineNotified      = false;
            isReset             = false;
            addedItems          = null;
            removedItems        = null;
            movedItems          = null;
            replaceAddedItems   = null;
            replaceRemovedItems = null;

            return(result);
        }
Ejemplo n.º 2
0
            public INotificationResult Notify(IList <INotificationResult> sources)
            {
                var change = (ICollectionChangedNotificationResult <T>)sources[0];

                var handler = CollectionChanged;

                if (handler != null)
                {
                    if (change.IsReset)
                    {
                        handler.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                    }
                    else
                    {
                        if (change.RemovedItems.Any())
                        {
                            handler.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, change.RemovedItems));
                        }
                        if (change.AddedItems.Any())
                        {
                            handler.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, change.AddedItems));
                        }
                    }
                }

                return(CollectionChangedNotificationResult <T> .Transfer(change, this));
            }
        public static CollectionChangedNotificationResult <T> Create(INotifiable source, bool isReset = false)
        {
            CollectionChangedNotificationResult <T> item;

            if (pool.TryTake(out item))
            {
                item.source = source;
                item.addedItems.Clear();
                item.removedItems.Clear();
                item.movedItems.Clear();
                item.isReset = isReset;
            }
            else
            {
                item = new CollectionChangedNotificationResult <T>(source, isReset);
            }
            return(item);
        }
Ejemplo n.º 4
0
        public INotificationResult AggregateChanges()
        {
            INotificationResult result;

            if (!HasChanges())
            {
                result = UnchangedNotificationResult.Instance;
            }
            else
            {
                result = notification;
            }

            engineNotified = false;
            notification   = CollectionChangedNotificationResult <T> .Create(null);

            return(result);
        }
Ejemplo n.º 5
0
 public virtual INotificationResult Notify(IList <INotificationResult> sources)
 {
     return(CollectionChangedNotificationResult <T> .Transfer(sources[0] as ICollectionChangedNotificationResult, this));
 }