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);
            }
        }
Пример #2
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);
            }
        }