public void Unsubscribe(INotifyCollectionChange observed) { if (logging) { /* * log.DebugFormat("Unsubscribed '{0}, {1}' from changes of property '{2}'", instance.GetType().Name, * intanceCredentials, change); */ } lock (observed) { // observedObjects.Remove(change); // cleanup objects being observed // change.ObserversObjects.Remove(this); // remember objects observing item observed.CollectionChanged -= observed_CollectionChanged; observed.CollectionChanging -= observed_CollectionChanging; } }
public void Subscribe(INotifyCollectionChange change) { if (logging) { /* * log.DebugFormat("Subscribed '{0}, {1}' to changes of property '{2}'", instance.GetType().Name, * intanceCredentials, change); */ } lock (change) { // observedObjects.Add(change); // remember objects being observed // change.ObserversObjects.Add(this); // remember objects observing item change.CollectionChanged += observed_CollectionChanged; change.CollectionChanging += observed_CollectionChanging; } }
private static void LogUnsubscribtions(object item, INotifyCollectionChange notifyCollectionChange, INotifyPropertyChange notifyPropertyChange) { if (!EventSettings.EnableLogging) return; if (notifyPropertyChange != null) log.DebugFormat("Unsubscribed Disconnected from property changes of: {0} ({1})", item, item.GetType().Name); if (notifyCollectionChange != null) log.DebugFormat("Unsubscribed Disconnected from collection changes of: {0} ({1})", item, item.GetType().Name); }
private static void LogSubscriptions(object item, INotifyCollectionChange notifyCollectionChange, INotifyPropertyChange notifyPropertyChange, bool newItem) { if (!EventSettings.EnableLogging) return; if (!newItem) { log.DebugFormat("Tried to subscribe disconnected, but was already subscribed as such: {0} ({1})", item, item.GetType().Name); return; } if (notifyPropertyChange != null) { log.DebugFormat("Subscribed Disconnected to property changes of: {0} ({1})", item, item.GetType().Name); } if (notifyCollectionChange != null) { log.DebugFormat("Subscribed Disconnected to collection changes of: {0} ({1})", item, item.GetType().Name); } }