public void RemoveListener(INotifyCollectionChanged collection, ICollectionChangedListener listener) { collection = collection ?? throw new ArgumentNullException(nameof(collection)); listener = listener ?? throw new ArgumentNullException(nameof(listener)); Dispatcher.UIThread.VerifyAccess(); if (_entries.TryGetValue(collection, out var listeners)) { for (var i = 0; i < listeners.Count; ++i) { if (listeners[i].TryGetTarget(out var target) && target == listener) { listeners.RemoveAt(i); if (listeners.Count == 0) { WeakSubscriptionManager.Unsubscribe( collection, nameof(INotifyCollectionChanged.CollectionChanged), this); _entries.Remove(collection); } return; } } } throw new InvalidOperationException( "Collection listener not registered for this collection/listener combination."); }
public void Dispose() { WeakSubscriptionManager.Unsubscribe( _collection, nameof(INotifyCollectionChanged.CollectionChanged), this); }
protected override void Deinitialize() { if (_sourceReference.TryGetTarget(out INotifyCollectionChanged instance)) { WeakSubscriptionManager.Unsubscribe( instance, nameof(instance.CollectionChanged), this); } }
protected override void Dispose(bool disposing) { var inpc = _reference.Target as INotifyPropertyChanged; if (inpc != null) { WeakSubscriptionManager.Unsubscribe( inpc, nameof(inpc.PropertyChanged), this); } }
public void Dispose() { var inpc = _reference.Target as INotifyPropertyChanged; if (inpc != null) { WeakSubscriptionManager.Unsubscribe( inpc, nameof(inpc.PropertyChanged), this); } }
protected override void UnsubscribeCore() { var inpc = GetReferenceTarget() as INotifyPropertyChanged; if (inpc != null) { WeakSubscriptionManager.Unsubscribe( inpc, nameof(inpc.PropertyChanged), this); } }
/// <summary> /// If the ItemsSource implements INotifyCollectionChanged update the visual when the collection changes. /// </summary> /// <param name="oldValue">The old ItemsSource</param> /// <param name="newValue">The new ItemsSource</param> private void SubscribeToCollectionChanged(IEnumerable oldValue, IEnumerable newValue) { if (oldValue is INotifyCollectionChanged collection) { WeakSubscriptionManager.Unsubscribe(collection, "CollectionChanged", eventListener); } collection = newValue as INotifyCollectionChanged; if (collection != null) { WeakSubscriptionManager.Subscribe(collection, "CollectionChanged", eventListener); } }
public override void Dispose() { base.Dispose(); var target = _reference.Target as INotifyDataErrorInfo; if (target != null) { WeakSubscriptionManager.Unsubscribe( target, nameof(target.ErrorsChanged), this); } }
private void DecrementCount() { if (--_count == 0) { if (_sourceReference.TryGetTarget(out INotifyCollectionChanged instance)) { WeakSubscriptionManager.Unsubscribe( instance, nameof(instance.CollectionChanged), this); } } }
protected override void UnsubscribeCore() { var target = GetReferenceTarget() as INotifyDataErrorInfo; if (target != null) { WeakSubscriptionManager.Unsubscribe( target, nameof(target.ErrorsChanged), this); } base.UnsubscribeCore(); }
private void DecrementCount() { if (--_count == 0) { IAvaloniaObject instance; if (_sourceReference.TryGetTarget(out instance)) { WeakSubscriptionManager.Unsubscribe( instance, nameof(instance.PropertyChanged), this); } } }
protected override void Unsubscribe(object target) { var incc = target as INotifyCollectionChanged; if (incc != null) { WeakSubscriptionManager.Unsubscribe <NotifyCollectionChangedEventArgs>( incc, nameof(incc.CollectionChanged), this); } var inpc = target as INotifyPropertyChanged; if (inpc != null) { WeakSubscriptionManager.Unsubscribe <PropertyChangedEventArgs>( inpc, nameof(inpc.PropertyChanged), this); } }