Ejemplo n.º 1
0
        private static void AddRoutedEventHandler(
            Hashtable table,
            RoutedEvent routedEvent,
            RoutedEventHandler handler,
            bool handledEventsToo)
        {
            if (routedEvent == null || handler == null)
            {
                throw new ArgumentNullException();
            }

            // Create a new RoutedEventHandler
            RoutedEventHandlerInfo routedEventHandlerInfo =
                new RoutedEventHandlerInfo(handler, handledEventsToo);

            // Get the entry corresponding to the given RoutedEvent
            ArrayList handlers = (ArrayList)table[routedEvent];
            if (handlers == null)
            {
                table[routedEvent] = (handlers = new ArrayList());
            }

            // Add the RoutedEventHandlerInfo to the list
            handlers.Add(routedEventHandlerInfo);
        }
Ejemplo n.º 2
0
        private bool HasClickEventHandler(object objectWithEvent)
        {
            object eventStore = objectWithEvent.GetType()
                                .GetProperty("EventHandlersStore", BindingFlags.Instance | BindingFlags.NonPublic)
                                .GetValue(objectWithEvent, null);

            if (eventStore != null)
            {
                RoutedEventHandlerInfo clickEvent = ((RoutedEventHandlerInfo[])eventStore
                                                     .GetType()
                                                     .GetMethod("GetRoutedEventHandlers", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                                                     .Invoke(eventStore, new object[] { Button.ClickEvent }))
                                                    .FirstOrDefault();

                if (clickEvent == default)
                {
                    return(false);
                }
                return(clickEvent.Handler?.Method.Name != null);
            }
            return(false);
        }
 public bool Equals(RoutedEventHandlerInfo handlerInfo)
 {
     return(this == handlerInfo);
 }
Ejemplo n.º 4
0
 /// <summary>
 ///     Is the given RoutedEventHandlerInfo equals the current
 /// </summary>
 public bool Equals(RoutedEventHandlerInfo handlerInfo) => this._handler == handlerInfo._handler && this._handledEventsToo == handlerInfo._handledEventsToo;
Ejemplo n.º 5
0
 /// <summary>
 /// Equalses the specified handler information.
 /// </summary>
 /// <param name="handlerInfo">The handler information.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public bool Equals(RoutedEventHandlerInfo handlerInfo)
 {
     return (this.Handler == handlerInfo.Handler) && (this.InvokeHandledEventsToo == handlerInfo.InvokeHandledEventsToo);
 }
 public bool Equals(RoutedEventHandlerInfo handlerInfo)
 {
   return this == handlerInfo;
 }
Ejemplo n.º 7
0
 // Constructor for RouteItem
 internal RouteItem(object target, RoutedEventHandlerInfo routedEventHandlerInfo)
 {
     this._target = target;
     this._routedEventHandlerInfo = routedEventHandlerInfo;
 }