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);
}
}
}
}