コード例 #1
0
ファイル: Bus.cs プロジェクト: kouweizhong/SeptaBus
        // 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);
        }
コード例 #2
0
        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));
        }