public EventHandlerOptions RegisterHandler <T>(IEventHandler <T> eventHandler)
        {
            EventHandlerOptions handlerOptions = new EventHandlerOptions(eventHandler);

            EventHandlers.Add <T>(handlerOptions);
            return(handlerOptions);
        }
Exemplo n.º 2
0
        internal void Add(Type eventType, EventHandlerOptions handler)
        {
            if (!Handlers.ContainsKey(eventType))
            {
                Handlers[eventType] = new List <EventHandlerOptions>();
            }

            Handlers[eventType].Add(handler);
        }
Exemplo n.º 3
0
        private void HandleError(EventHandlerOptions eventhandlerOptions, Exception ex)
        {
            if (ErrorHandler != null)
            {
                ErrorHandler(ex);
            }

            if (eventhandlerOptions.ErrorHandler != null)
            {
                eventhandlerOptions.ErrorHandler(ex);
            }
        }
        public IList <EventHandlerOptions> RegisterHandlers(object eventHandler)
        {
            List <EventHandlerOptions> handlerOptionsList = new List <EventHandlerOptions>();

            Type[] handlers = eventHandler.GetType().GetInterfaces();

            Type eventHandlerType = typeof(IEventHandler <>);

            foreach (Type handler in handlers)
            {
                if (handler.Name.Equals(eventHandlerType.Name))
                {
                    Type eventType = handler.GetGenericArguments()[0];
                    EventHandlerOptions handlerOptions = new EventHandlerOptions(eventHandler);
                    EventHandlers.Add(eventType, handlerOptions);
                    handlerOptionsList.Add(handlerOptions);
                }
            }

            return(handlerOptionsList);
        }
Exemplo n.º 5
0
        internal void Add <T>(EventHandlerOptions handler)
        {
            Type handleType = typeof(T);

            Add(handleType, handler);
        }