/// <summary> /// Detaches the <c>PropertyChanged</c> event handlers /// </summary> public virtual void ClearEvents() { var invocation = PropertyChanged?.GetInvocationList() ?? new Delegate[0]; foreach (var property in invocation) { PropertyChanged -= (PropertyChangedEventHandler)property; } }
public void Subscribe(PropertyChangedEventHandler handler) { if (handler != null) { if (!PropertyChanged?.GetInvocationList().Contains(handler) ?? true) { PropertyChanged += handler; } } }
public void Unsubscribe(PropertyChangedEventHandler handler) { if (handler != null) { if (!PropertyChanged?.GetInvocationList()?.Contains(handler) ?? false) { PropertyChanged -= handler; } } }
public void Subscribe(PropertyChangedEventHandler handler) { if (handler != null) { if (!PropertyChanged?.GetInvocationList().Contains(handler) ?? true) { PropertyChanged += handler; System.Diagnostics.Debug.WriteLine($"Initializing PropertyChangedHandler for {GetType().Name}"); } } }
public virtual void Dispose() { // remove event handlers before setting event to null Delegate[] delegates = PropertyChanged?.GetInvocationList(); if ((delegates?.Length ?? 0) > 0) { // ReSharper disable once PossibleNullReferenceException foreach (var d in delegates) { PropertyChanged -= (PropertyChangedEventHandler)d; } } PropertyChanged = null; _view = null; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (OnClose != null) { foreach (var d in OnClose.GetInvocationList()) { OnClose -= (Action <object, DialogResult>)d; } } if (PropertyChanged != null) { foreach (var d in PropertyChanged.GetInvocationList()) { PropertyChanged -= (PropertyChangedEventHandler)d; } } }
private void HandleObservableCollectionChanged(object value, NotifyCollectionChangedEventArgs e) { string settingName = SettingsValues.FirstOrDefault(x => x.Value == value).Key; var settingValueChangedInvocationList = SettingValueChanged.GetInvocationList(); foreach (var item in settingValueChangedInvocationList) { Task.Run(() => (item as Action <string, object>).Invoke(settingName, value)); } var propertyChangedInvocationList = PropertyChanged.GetInvocationList(); foreach (var item in propertyChangedInvocationList) { Task.Run(() => (item as PropertyChangedEventHandler).Invoke(this, new PropertyChangedEventArgs(settingName))); } }
private void DynItem_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (PropertyChanged != null) { foreach (PropertyChangedEventHandler handler in PropertyChanged.GetInvocationList()) { var dispatcherObject = handler.Target as DispatcherObject; if (dispatcherObject != null && !dispatcherObject.CheckAccess()) { dispatcherObject.Dispatcher.BeginInvoke(handler, DispatcherPriority.DataBind, this, e); } else { handler(this, e); } } } }
protected virtual void OnPropertyChanged(bool IgnoreDirtyState = false, [CallerMemberName] string PropertyName = "") { try { if (PropertyChanged != null) { foreach (PropertyChangedEventHandler _singleCast_ in PropertyChanged.GetInvocationList()) { try { if ((_singleCast_.Target is ISynchronizeInvoke _syncInvoke_) && _syncInvoke_.InvokeRequired) { _syncInvoke_.Invoke(_singleCast_, new object[] { this, new PropertyChangedEventArgs(PropertyName) }); } else { _singleCast_(this, new PropertyChangedEventArgs(PropertyName)); } } catch { } }
internal void Dispose() { if (PropertyChanged != null) { var invocationList = PropertyChanged.GetInvocationList(); foreach (var handler in invocationList) { PropertyChanged -= handler as PropertyChangedEventHandler; } PropertyChanged = null; } segment = null; item = null; series = null; trendline = null; legend = null; XFormsLabelStyle = null; XFormsLegendItem = null; }
public int GetPropertyChangedSubscribledLength() { return(PropertyChanged?.GetInvocationList()?.Length ?? 0); }
private PropertyChangedEventHandler[] GetHandlers() { return(PropertyChanged?.GetInvocationList().OfType <PropertyChangedEventHandler>().ToArray()); }
public int GetPropertyChangedEventHandlerSubscriberLength() { return(PropertyChanged is null ? 0 : PropertyChanged.GetInvocationList().Length); }
public void ClearPropertyChanged() { InvocationList = PropertyChanged.GetInvocationList(); PropertyChanged = null; }
/// <summary> /// Returns the list of delegates that are currently subscribed for the /// <see cref="System.ComponentModel.INotifyPropertyChanged">INotifyPropertyChanged</see> /// PropertyChanged event /// </summary> public Delegate[] GetINPCSubscribers() { return(PropertyChanged == null ? null : PropertyChanged.GetInvocationList()); }
public PropertyChangedEventHandler[] GetPropertyChangedHandlers() { return(PropertyChanged.GetInvocationList(). OfType <PropertyChangedEventHandler>().ToArray()); }
public Delegate[] GetPropertyChangedInvocationList() { return(PropertyChanged.GetInvocationList()); }
public System.Delegate[] GetInvocationList() { return(PropertyChanged?.GetInvocationList()); }
public int GetPropertyChangedSubscriberCount() => PropertyChanged?.GetInvocationList().Length ?? 0;