コード例 #1
0
        public Task <TCommandResult> Dispatch <TCommand, TCommandResult>(TCommand command) where TCommand : class where TCommandResult : class
        {
            var commandHandler = commandHandlerFactory.Create <TCommand, TCommandResult>(command);

            try
            {
                return(commandHandler.Handle(command));
            }
            finally
            {
                commandHandlerFactory.Destroy(commandHandler);
            }
        }
コード例 #2
0
        public CommandResult <TReturn> Execute <TCommand, TReturn>(TCommand command)
        {
            ICommandHandler <TCommand, TReturn> handler = _commandHandlerFactory.Create <TCommand, TReturn>();

            try
            {
                var returnValue = handler.Handle(command);
                return(CommandResult <TReturn> .Executed(returnValue));
            }
            finally
            {
                _commandHandlerFactory.Destroy(handler);
            }
        }