Exemplo n.º 1
0
        /// <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;
            }
        }
Exemplo n.º 2
0
 public void Subscribe(PropertyChangedEventHandler handler)
 {
     if (handler != null)
     {
         if (!PropertyChanged?.GetInvocationList().Contains(handler) ?? true)
         {
             PropertyChanged += handler;
         }
     }
 }
Exemplo n.º 3
0
 public void Unsubscribe(PropertyChangedEventHandler handler)
 {
     if (handler != null)
     {
         if (!PropertyChanged?.GetInvocationList()?.Contains(handler) ?? false)
         {
             PropertyChanged -= handler;
         }
     }
 }
Exemplo n.º 4
0
 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}");
         }
     }
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 /// <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;
         }
     }
 }
Exemplo n.º 7
0
        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)));
            }
        }
Exemplo n.º 8
0
 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);
             }
         }
     }
 }
Exemplo n.º 9
0
 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 { }
             }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
0
 public int GetPropertyChangedSubscribledLength()
 {
     return(PropertyChanged?.GetInvocationList()?.Length ?? 0);
 }
Exemplo n.º 12
0
 private PropertyChangedEventHandler[] GetHandlers()
 {
     return(PropertyChanged?.GetInvocationList().OfType <PropertyChangedEventHandler>().ToArray());
 }
 public int GetPropertyChangedEventHandlerSubscriberLength()
 {
     return(PropertyChanged is null ? 0 : PropertyChanged.GetInvocationList().Length);
 }
Exemplo n.º 14
0
 public void ClearPropertyChanged()
 {
     InvocationList = PropertyChanged.GetInvocationList(); PropertyChanged = null;
 }
Exemplo n.º 15
0
 /// <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());
 }
Exemplo n.º 17
0
 public Delegate[] GetPropertyChangedInvocationList()
 {
     return(PropertyChanged.GetInvocationList());
 }
Exemplo n.º 18
0
 public System.Delegate[] GetInvocationList()
 {
     return(PropertyChanged?.GetInvocationList());
 }
Exemplo n.º 19
0
 public int GetPropertyChangedSubscriberCount() => PropertyChanged?.GetInvocationList().Length ?? 0;