public void SubscribeNotifyChangedEvents(object value, ICollection parentCollection)
{
if (value == null)
{
return;
}
lock (_lockObject)
{
var collectionChangedValue = value as INotifyCollectionChanged;
if (collectionChangedValue != null)
{
SubscribeNotifyChangedEvent(collectionChangedValue, EventChangeType.Collection, parentCollection);
var collection = value as ICollection;
if (collection != null)
{
foreach (var child in collection)
{
SubscribeNotifyChangedEvents(child, collection);
}
}
}
var propertyChangedValue = value as INotifyPropertyChanged;
if (propertyChangedValue != null)
{
// ObservableObject implements PropertyChanged as protected, make sure we accept that in non-.NET languages such
// as Silverlight, Windows Phone and WinRT
try
{
SubscribeNotifyChangedEvent(propertyChangedValue, EventChangeType.Property, parentCollection);
}
catch (Exception ex)
{
Log.Warning(ex, "Failed to subscribe to PropertyChanged event, the event is probably not public");
}
}
}
}