Catel.Data.ChangeNotificationWrapper.UnsubscribeNotifyChangedEvents C# (CSharp) Method

UnsubscribeNotifyChangedEvents() public method

Unsubscribes from the notify changed events.
No need to check for weak events, they are unsubscribed automatically.
public UnsubscribeNotifyChangedEvents ( object value, ICollection parentCollection ) : void
value object The object to unsubscribe from.
parentCollection ICollection The parent collection.
return void
        public void UnsubscribeNotifyChangedEvents(object value, ICollection parentCollection)
        {
            if (value == null)
            {
                return;
            }

            lock (_lockObject)
            {
                var propertyChangedValue = value as INotifyPropertyChanged;
                if (propertyChangedValue != null)
                {
                    UnsubscribeNotifyChangedEvent(propertyChangedValue, EventChangeType.Property, parentCollection);
                }

                var collectionChangedValue = value as INotifyCollectionChanged;
                if (collectionChangedValue != null)
                {
                    UnsubscribeNotifyChangedEvent(collectionChangedValue, EventChangeType.Collection, parentCollection);

                    foreach (var child in (IEnumerable)value)
                    {
                        UnsubscribeNotifyChangedEvents(child, parentCollection);
                    }
                }
            }
        }