/// <summary> /// Removes an instance of the specified /// Clr event handler for the given /// EventPrivateKey from the store /// </summary> /// <param name="key"> /// Private key for the event /// </param> /// <param name="handler"> /// Event handler /// </param> /// <remarks> /// NOTE: This method does nothing if no /// matching handler instances are found /// in the store /// </remarks> public void Remove(EventPrivateKey key, Delegate handler) { if (key == null) { throw new ArgumentNullException("key"); } if (handler == null) { throw new ArgumentNullException("handler"); } // Get the entry corresponding to the given key Delegate existingDelegate = (Delegate)this[key]; if (existingDelegate != null) { existingDelegate = Delegate.Remove(existingDelegate, handler); if (existingDelegate == null) { // last handler for this event was removed -- reclaim space in // underlying FrugalMap by setting value to DependencyProperty.UnsetValue _entries[key.GlobalIndex] = DependencyProperty.UnsetValue; } else { _entries[key.GlobalIndex] = existingDelegate; } } }
public void Add(EventPrivateKey key, Delegate handler) { if (_directEventHandlers == null) { _directEventHandlers = new EventHandlerList(); } _directEventHandlers.AddHandler(key, handler); }
public Delegate Get(EventPrivateKey key) { if (_directEventHandlers == null) { return(null); } return(_directEventHandlers[key]); }
public void Remove(EventPrivateKey key, Delegate handler) { if (_directEventHandlers == null) { return; } _directEventHandlers.RemoveHandler(key, handler); }
public Delegate Get(EventPrivateKey key) { if (_directEventHandlers == null) { return null; } return _directEventHandlers[key]; }
/// <summary> /// Gets all the handlers for the given EventPrivateKey /// </summary> /// <param name="key"> /// Private key for the event /// </param> /// <returns> /// Combined delegate or null if no match found /// </returns> /// <remarks> /// This method is not exposing a security risk for the reason /// that the EventPrivateKey for the events will themselves be /// private to the declaring class. This will be enforced via fxcop rules. /// </remarks> public Delegate Get(EventPrivateKey key) { if (key == null) { throw new ArgumentNullException("key"); } // Return the handlers corresponding to the given key return((Delegate)this[key]); }
private void RaiseMouseButtonEvent(EventPrivateKey key, MouseButtonEventArgs e) { EventHandlersStore store = EventHandlersStore; if (store != null) { Delegate handler = store.Get(key); if (handler != null) { ((MouseButtonEventHandler)handler)(this, e); } } }
// Helper method to retrieve and fire Clr Event handlers for DependencyPropertyChanged event private void RaiseDependencyPropertyChanged(EventPrivateKey key, DependencyPropertyChangedEventArgs args) { EventHandlersStore store = EventHandlersStore; if (store != null) { Delegate handler = store.Get(key); if (handler != null) { ((DependencyPropertyChangedEventHandler)handler)(this, args); } } }
internal Delegate this[EventPrivateKey key] { get { Debug.Assert(key != null, "Search key cannot be null"); object existingDelegate = _entries[key.GlobalIndex]; if (existingDelegate == DependencyProperty.UnsetValue) { return(null); } else { return((Delegate)existingDelegate); } } }
/// <summary> /// Adds a Clr event handler for the /// given EventPrivateKey to the store /// </summary> /// <param name="key"> /// Private key for the event /// </param> /// <param name="handler"> /// Event handler /// </param> public void Add(EventPrivateKey key, Delegate handler) { if (key == null) { throw new ArgumentNullException("key"); } if (handler == null) { throw new ArgumentNullException("handler"); } // Get the entry corresponding to the given key Delegate existingDelegate = (Delegate)this[key]; if (existingDelegate == null) { _entries[key.GlobalIndex] = handler; } else { _entries[key.GlobalIndex] = Delegate.Combine(existingDelegate, handler); } }
private void EventHandlersStoreRemove(EventPrivateKey key, Delegate handler) { EventHandlersStore store = EventHandlersStore; if (store != null) { store.Remove(key, handler); if (store.Count == 0) { // last event handler was removed -- throw away underlying EventHandlersStore EventHandlersStoreField.ClearValue(this); WriteFlag(CoreFlags.ExistsEventHandlersStore, false); } } }
private void EventHandlersStoreAdd(EventPrivateKey key, Delegate handler) { EnsureEventHandlersStore(); EventHandlersStore.Add(key, handler); }
private void EventHandlersStoreRemove(EventPrivateKey key, Delegate handler) { EventHandlersStore store = EventHandlersStore; if (store != null) { store.Remove(key, handler); } }
internal void EventHandlersStoreAdd(EventPrivateKey key, Delegate handler) { this.EnsureEventHandlersStore(); this.EventHandlersStore.Add(key, handler); }
/// <summary> /// Removes a delegate from the list of event handlers on this object. /// </summary> /// <param name="key"> /// A unique identifier for the event handler. /// </param> /// <param name="handler">The delegate to remove.</param> private void RemoveEventHandler(EventPrivateKey key, Delegate handler) { WritePreamble(); EventHandlersStore store = EventHandlersStoreField.GetValue(this); if (store != null) { store.Remove(key, handler); if (store.Count == 0) { // last event handler was removed -- throw away underlying EventHandlersStore EventHandlersStoreField.ClearValue(this); } WritePostscript(); } }
/// <summary> /// Removes an instance of the specified /// Clr event handler for the given /// EventPrivateKey from the store /// </summary> /// <param name="key"> /// Private key for the event /// </param> /// <param name="handler"> /// Event handler /// </param> /// <remarks> /// NOTE: This method does nothing if no /// matching handler instances are found /// in the store /// </remarks> public void Remove(EventPrivateKey key, Delegate handler) { if (key == null) { throw new ArgumentNullException("key"); } if (handler == null) { throw new ArgumentNullException("handler"); } // Get the entry corresponding to the given key Delegate existingDelegate = (Delegate) this[key]; if (existingDelegate != null) { existingDelegate = Delegate.Remove(existingDelegate, handler); if (existingDelegate == null) { // last handler for this event was removed -- reclaim space in // underlying FrugalMap by setting value to DependencyProperty.UnsetValue _entries[key.GlobalIndex] = DependencyProperty.UnsetValue; } else { _entries[key.GlobalIndex] = existingDelegate; } } }
private void RaiseInitialized(EventPrivateKey key, EventArgs e) { EventHandlersStore eventHandlersStore = this.EventHandlersStore; if (eventHandlersStore == null) return; Delegate @delegate = eventHandlersStore.Get(key); if (@delegate == null) return; ((EventHandler) @delegate)((object) this, e); }
private void RaiseDependencyPropertyChanged(EventPrivateKey key, DependencyPropertyChangedEventArgs args) { EventHandlersStore eventHandlersStore = this.EventHandlersStore; if (eventHandlersStore == null) return; Delegate @delegate = eventHandlersStore.Get(key); if (@delegate == null) return; ((DependencyPropertyChangedEventHandler) @delegate)((object) this, args); }
internal void RaiseClrEvent(EventPrivateKey key, EventArgs args) { EventHandlersStore eventHandlersStore = this.EventHandlersStore; if (eventHandlersStore == null) return; Delegate @delegate = eventHandlersStore.Get(key); if (@delegate == null) return; ((EventHandler) @delegate)((object) this, args); }
internal void EventHandlersStoreRemove(EventPrivateKey key, Delegate handler) { EventHandlersStore eventHandlersStore = this.EventHandlersStore; if (eventHandlersStore == null) return; eventHandlersStore.Remove(key, handler); }
internal Delegate this[EventPrivateKey key] { get { Debug.Assert(key != null, "Search key cannot be null"); object existingDelegate = _entries[key.GlobalIndex]; if (existingDelegate == DependencyProperty.UnsetValue) { return null; } else { return (Delegate)existingDelegate; } } }
/// <summary> /// Gets all the handlers for the given EventPrivateKey /// </summary> /// <param name="key"> /// Private key for the event /// </param> /// <returns> /// Combined delegate or null if no match found /// </returns> /// <remarks> /// This method is not exposing a security risk for the reason /// that the EventPrivateKey for the events will themselves be /// private to the declaring class. This will be enforced via fxcop rules. /// </remarks> public Delegate Get(EventPrivateKey key) { if (key == null) { throw new ArgumentNullException("key"); } // Return the handlers corresponding to the given key return (Delegate)this[key]; }
// Helper method to retrieve and fire Clr Event handlers for Initialized event private void RaiseInitialized(EventPrivateKey key, EventArgs e) { EventHandlersStore store = EventHandlersStore; if (store != null) { Delegate handler = store.Get(key); if (handler != null) { ((EventHandler)handler)(this, e); } } }
/// <summary> /// Adds a delegate to the list of event handlers on this object. /// </summary> /// <param name="key"> /// A unique identifier for the event handler. /// </param> /// <param name="handler">The delegate to add.</param> private void AddEventHandler(EventPrivateKey key, Delegate handler) { WritePreamble(); EventHandlersStore store = EventHandlersStoreField.GetValue(this); if (store == null) { store = new EventHandlersStore(); EventHandlersStoreField.SetValue(this, store); } store.Add(key, handler); WritePostscript(); }
// Helper method to retrieve and fire Clr Event handlers internal void RaiseClrEvent(EventPrivateKey key, EventArgs args) { EventHandlersStore store = EventHandlersStore; if (store != null) { Delegate handler = store.Get(key); if (handler != null) { ((EventHandler)handler)(this, args); } } }