Beispiel #1
0
        /*============================================================================*/
        /* Public Functions                                                           */
        /*============================================================================*/

        public void MapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
        {
            if (eventClass == null)
            {
                eventClass = typeof(Event);
            }

            List <EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;

            EventMapConfig config;

            int i = currentListeners.Count;

            while (i-- > 0)
            {
                config = currentListeners [i];
                if (config.Equals(dispatcher, type, listener, eventClass))
                {
                    return;
                }
            }

            Delegate callback = eventClass == typeof(Event) ? listener : (Action <IEvent>) delegate(IEvent evt){
                RouteEventToListener(evt, listener, eventClass);
            };

            config = new EventMapConfig(dispatcher, type, listener, eventClass, callback);

            currentListeners.Add(config);

            if (!_suspended)
            {
                dispatcher.AddEventListener(type, callback);
            }
        }
 public void setUp()
 {
     instance = new EventMapConfig(
         DISPATCHER,
         EVENT_TYPE,
         LISTENER,
         EVENT_CLASS,
         CALLBACK);
 }
 public void tearDown()
 {
     instance = null;
 }