コード例 #1
0
        public CommandResult ExecuteCommand(Command command)
        {
            dynamic handler = FindHandlerForCommand(command);

            try
            {
                handler.Handle(command as dynamic);
                return CommandResult.Executed("Command executed successfully");
            }
            finally
            {
                _kernel.Release(handler);
            }
        }
コード例 #2
0
        public Task<CommandResult> ExecuteCommandAsync(Command command)
        {
            dynamic handler = FindHandlerForCommand(command);

            try
            {
                var task = Task.Run(() =>
                    {
                        handler.Handle(command as dynamic);
                        return CommandResult.Executed("Command executed successfully");
                    });

                return task;
            }
            finally
            {
                _kernel.Release(handler);
            }
        }
コード例 #3
0
 protected CommandResult Execute(Command command)
 {
     return MvcApplication.CommandExecutor.ExecuteCommand(command);
 }
コード例 #4
0
 private object FindHandlerForCommand(Command command)
 {
     var handlerType = typeof(IHandleCommand<>).MakeGenericType(command.GetType());
     dynamic handler = _kernel.Get(handlerType);
     return handler;
 }