Beispiel #1
0
        private void DoAddSubscription(Type handlerType, string commandName)
        {
            if (!HasSubscriptionsForCommand(commandName))
            {
                _handlers.Add(commandName, new List <CommandSubscriptionInfo>());
            }

            if (_handlers[commandName].Any())
            {
                throw new ArgumentException($"Handler already registered for '{commandName}'");
            }

            _handlers[commandName].Add(CommandSubscriptionInfo.Typed(handlerType));
        }
 private void DoRemoveHandler(string commandName, CommandSubscriptionInfo subsToRemove)
 {
     if (subsToRemove != null)
     {
         _handlers[commandName].Remove(subsToRemove);
         if (!_handlers[commandName].Any())
         {
             _handlers.Remove(commandName);
             var commandType = _commandTypes.SingleOrDefault(e => e.Name == commandName);
             if (commandType != null)
             {
                 _commandTypes.Remove(commandType);
             }
             RaiseOnCommandRemoved(commandName);
         }
     }
 }
        private void DoAddSubscription(string commandName, Type commandType, Type returnType, Type handlerType, bool isDynamic)
        {
            if (!_handlers.ContainsKey(commandName))
            {
                _handlers.Add(commandName, new List <CommandSubscriptionInfo>());
            }

            if (_handlers[commandName].Any())
            {
                throw new ArgumentException($"Handler already registered for '{commandName}'");
            }

            if (isDynamic)
            {
                _handlers[commandName].Add(CommandSubscriptionInfo.Dynamic(commandName, returnType, handlerType));
            }
            else
            {
                _handlers[commandName].Add(CommandSubscriptionInfo.Typed(commandName, commandType, returnType, handlerType));
            }
        }