/// <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;
                }
            }
        }
Ejemplo n.º 2
0
        public void Add(EventPrivateKey key, Delegate handler)
        {
            if (_directEventHandlers == null)
            {
                _directEventHandlers = new EventHandlerList();
            }

            _directEventHandlers.AddHandler(key, handler);
        }
Ejemplo n.º 3
0
        public Delegate Get(EventPrivateKey key)
        {
            if (_directEventHandlers == null)
            {
                return(null);
            }

            return(_directEventHandlers[key]);
        }
Ejemplo n.º 4
0
        public void Remove(EventPrivateKey key, Delegate handler)
        {
            if (_directEventHandlers == null)
            {
                return;
            }

            _directEventHandlers.RemoveHandler(key, handler);
        }
    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];
    }
    public void Add(EventPrivateKey key, Delegate handler)
    {
      if (_directEventHandlers == null)
      {
        _directEventHandlers = new EventHandlerList();
      }

      _directEventHandlers.AddHandler(key, handler);
    }
        /// <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]);
        }
Ejemplo n.º 9
0
        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);
                }
            }
        }
Ejemplo n.º 10
0
        // 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);
                }
            }
        }
Ejemplo n.º 12
0
        /// <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);
            } 
        } 
        /// <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);
            }
        }
Ejemplo n.º 14
0
 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);
         }
     }
 }
Ejemplo n.º 15
0
 private void EventHandlersStoreAdd(EventPrivateKey key, Delegate handler)
 {
     EnsureEventHandlersStore();
     EventHandlersStore.Add(key, handler);
 }
Ejemplo n.º 16
0
 private void EventHandlersStoreRemove(EventPrivateKey key, Delegate handler)
 { 
     EventHandlersStore store = EventHandlersStore;
     if (store != null)
     {
         store.Remove(key, handler); 
     }
 } 
Ejemplo n.º 17
0
 internal void EventHandlersStoreAdd(EventPrivateKey key, Delegate handler)
 {
     this.EnsureEventHandlersStore();
       this.EventHandlersStore.Add(key, handler);
 }
Ejemplo n.º 18
0
        /// <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();
            }
        }
Ejemplo n.º 19
0
        /// <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;
                } 
            } 
        }
Ejemplo n.º 20
0
 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);
 }
Ejemplo n.º 21
0
 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);
 }
Ejemplo n.º 22
0
 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);
 }
Ejemplo n.º 23
0
 internal void EventHandlersStoreRemove(EventPrivateKey key, Delegate handler)
 {
     EventHandlersStore eventHandlersStore = this.EventHandlersStore;
       if (eventHandlersStore == null)
     return;
       eventHandlersStore.Remove(key, handler);
 }
Ejemplo n.º 24
0
        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;
                } 
            }
        } 
Ejemplo n.º 25
0
        /// <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];
        } 
Ejemplo n.º 26
0
 // 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); 
         }
     }
 }
Ejemplo n.º 27
0
        /// <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();
        }
Ejemplo n.º 28
0
 // 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); 
         }
     } 
 }
Ejemplo n.º 29
0
 // 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); 
         } 
     }
 } 
Ejemplo n.º 30
0
 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); 
         }
     }
 }