Ejemplo n.º 1
0
 private void DoRemoveHandler(string eventName, SubscribeInfo subscribeInfo)
 {
     if (subscribeInfo != null)
     {
         _handlers[eventName].Remove(subscribeInfo);
         if (!_handlers[eventName].Any())
         {
             _handlers.Remove(eventName);
             var eventType = _eventTypes.SingleOrDefault(o => o.Name == eventName);
             if (eventType != null)
             {
                 _eventTypes.Remove(eventType);
             }
             RaiseOnEventRemoved(eventName);
         }
     }
 }
Ejemplo n.º 2
0
        private void DoAddSubscribe(Type handlerType, string eventName, bool isDynamic)
        {
            if (!_handlers.ContainsKey(eventName))
            {
                _handlers.Add(eventName, new List <SubscribeInfo>());
            }

            if (_handlers[eventName].Any(o => o.HandlerType == handlerType))
            {
                throw new ArgumentException($"Handler Type: {handlerType.Name} has registered for {eventName}");
            }

            if (isDynamic)
            {
                _handlers[eventName].Add(SubscribeInfo.Dynamic(handlerType));
            }
            else
            {
                _handlers[eventName].Add(SubscribeInfo.Typed(handlerType));
            }
        }