Beispiel #1
0
        // Invoked via reflection, so:
        // ReSharper disable once UnusedMember.Local
        private void SendInternal <TCommand>(TCommand command) where TCommand : class, ICommand
        {
            var handler = _handlerProvider.GetCommandHandler(command);

            if (handler == null)
            {
                throw new Exception(string.Format("There is no handler registered for the command of type '{0}'.",
                                                  command.GetType()));
            }

            handler.Handle(command);
        }
        public Task <ApiResponse <Unit> > Execute <TCommand>(TConnection connection, TCommand command)
            where TCommand : ICommand
        {
            var commandHandler = _handlerProvider.GetCommandHandler <TCommand>();

            var context = CommandExecutionContext.Create(
                connection,
                commandHandler,
                command);

            return(_executor.Execute(context));
        }