Esempio n. 1
0
 /// <summary>
 /// Gets the updated d typed class listeners.
 /// </summary>
 /// <param name="dependencyType">Type of the dependency.</param>
 /// <param name="routedEvent">The routed event.</param>
 /// <param name="classListenersLists">The class listeners lists.</param>
 /// <param name="index">The index.</param>
 /// <returns>RoutedEventHandlerInfoList.</returns>
 private static RoutedEventHandlerInfoList GetUpdatedDTypedClassListeners(DependencyObjectType dependencyType, RoutedEvent routedEvent, out ClassHandlersStore classListenersLists, out int index)
 {
     classListenersLists = (ClassHandlersStore)dependencyTypedClassListeners[dependencyType];
     if (classListenersLists != null)
     {
         index = classListenersLists.GetHandlersIndex(routedEvent);
         if (index != -1)
         {
             return classListenersLists.GetExistingHandlers(index);
         }
     }
     var baseType = dependencyType;
     ClassHandlersStore store = null;
     RoutedEventHandlerInfoList handlers = null;
     var handlersIndex = -1;
     while ((handlersIndex == -1) && (baseType.Id != dependencyObjectType.Id))
     {
         baseType = baseType.BaseType;
         store = (ClassHandlersStore)dependencyTypedClassListeners[baseType];
         if (store != null)
         {
             handlersIndex = store.GetHandlersIndex(routedEvent);
             if (handlersIndex != -1)
             {
                 handlers = store.GetExistingHandlers(handlersIndex);
             }
         }
     }
     if (classListenersLists == null)
     {
         if (dependencyType.SystemType == typeof(UIElement))
         {
             classListenersLists = new ClassHandlersStore(80);
         }
         else
         {
             classListenersLists = new ClassHandlersStore(1);
         }
         dependencyTypedClassListeners[dependencyType] = classListenersLists;
     }
     index = classListenersLists.CreateHandlersLink(routedEvent, handlers);
     return handlers;
 }
Esempio n. 2
0
 /// <summary>
 /// Gets the d typed class listeners.
 /// </summary>
 /// <param name="dependencyType">Type of the dependency.</param>
 /// <param name="routedEvent">The routed event.</param>
 /// <param name="classListenersLists">The class listeners lists.</param>
 /// <param name="index">The index.</param>
 /// <returns>RoutedEventHandlerInfoList.</returns>
 internal static RoutedEventHandlerInfoList GetDTypedClassListeners(DependencyObjectType dependencyType, RoutedEvent routedEvent, out ClassHandlersStore classListenersLists, out int index)
 {
     classListenersLists = (ClassHandlersStore)dependencyTypedClassListeners[dependencyType];
     if (classListenersLists != null)
     {
         index = classListenersLists.GetHandlersIndex(routedEvent);
         if (index != -1)
         {
             return classListenersLists.GetExistingHandlers(index);
         }
     }
     lock (synchronized)
     {
         return GetUpdatedDTypedClassListeners(dependencyType, routedEvent, out classListenersLists, out index);
     }
 }