Пример #1
0
        public SubscriptionTree CreateSubscriptionTree(INotifyPropertyChanged parameter)
        {
            List <SubscriptionNode> subscribers = new List <SubscriptionNode>(this.Children.Count);

            for (int i = 0; i < this.Children.Count; i++)
            {
                PropertyAccessTreeNode child = this.Children[i];
                if (child.Children.Count > 0)
                {
                    var subscriptionNode = child.CreateSubscription(parameter);
                    subscribers.Add(subscriptionNode);
                }
            }
            var subscriptionTree = new SubscriptionTree(parameter, subscribers);

            return(subscriptionTree);
        }
        private void SubscribeToItem(T item)
        {
            bool wasFirstTimeAddedToCollection = this.ReferenceCountTracker.Add(item);

            if (!wasFirstTimeAddedToCollection || !this.IsMonitoringChildProperties)
            {
                return;
            }

            if (_propertyChangedSubscription != null)
            {
                _propertyChangedSubscription.SubscribeToChanges((INotifyPropertyChanged)item, this);
            }
            else
            {
                SubscriptionTree subscriptionTree = this.PropertyAccessTree.CreateSubscriptionTree((INotifyPropertyChanged)item);
                subscriptionTree.PropertyChanged += OnAnyPropertyChangeInSubscriptionTree;
                this.Subscriptions.Add(item, subscriptionTree);
            }
        }
Пример #3
0
        internal void SubscribeToChanges(T subject)
        {
            if (EntireTreeSupportINotifyPropertyChanging)
            {
                if (_PropertyAccessTree == null)
                {
                    _PropertyAccessTree = PropertyAccessTree.CreateCallbackSubscription <PropertyNotifier <T> >(OnItemChanging, OnItemChanged);
                }
                _PropertyAccessTree.SubscribeToChanges(subject, this);
            }
            else
            {
                if (_Subscriptions == null)
                {
                    _Subscriptions = new Dictionary <T, SubscriptionTree>();
                }

                SubscriptionTree tree = PropertyAccessTree.CreateSubscriptionTree(subject);
                tree.PropertyChanged += OnAnyPropertyChangeInSubscriptionTree;
                _Subscriptions.Add(subject, tree);
            }
        }
Пример #4
0
 private void OnAnyPropertyChangeInSubscriptionTree(SubscriptionTree sender)
 {
     OnItemChanged(this, sender.Parameter, null);
 }
 void OnAnyPropertyChangeInSubscriptionTree(SubscriptionTree sender)
 {
     OnAnyPropertyChange(this, sender.Parameter);
 }