Catel.Data.ModelBase.HandleObjectEventsSubscription C# (CSharp) 메소드

HandleObjectEventsSubscription() 개인적인 메소드

Handles the object events subscription. This means that the old value will be removed from the event subscriptions, and the new value will be subscribed to.
private HandleObjectEventsSubscription ( string propertyName, object propertyValue ) : void
propertyName string Name of the property.
propertyValue object The property value.
리턴 void
        private void HandleObjectEventsSubscription(string propertyName, object propertyValue)
        {
            if (DisableEventSubscriptionsOfChildValues)
            {
                return;
            }

            lock (_propertyValuesLock)
            {
                ChangeNotificationWrapper oldWrapper;

                if (_propertyValueChangeNotificationWrappers.TryGetValue(propertyName, out oldWrapper))
                {
                    oldWrapper.PropertyChanged -= OnPropertyObjectPropertyChanged;
                    oldWrapper.CollectionChanged -= OnPropertyObjectCollectionChanged;
                    oldWrapper.CollectionItemPropertyChanged -= OnPropertyObjectCollectionItemPropertyChanged;
                    oldWrapper.UnsubscribeFromAllEvents();
                }

                if (!ChangeNotificationWrapper.IsUsefulForObject(propertyValue))
                {
                    if (oldWrapper != null)
                    {
                        _propertyValueChangeNotificationWrappers.Remove(propertyName);
                    }
                }
                else
                {
                    var wrapper = new ChangeNotificationWrapper(propertyValue);
                    wrapper.PropertyChanged += OnPropertyObjectPropertyChanged;
                    wrapper.CollectionChanged += OnPropertyObjectCollectionChanged;
                    wrapper.CollectionItemPropertyChanged += OnPropertyObjectCollectionItemPropertyChanged;
                    _propertyValueChangeNotificationWrappers[propertyName] = wrapper;
                }
            }
        }