Beispiel #1
0
        private object HandleCommandResult(CommandSet commandSet, object result)
        {
            var commandResult = result as CommandResult;

            if (commandResult != null)
            {
                var command = (Command)commandSet.Command;
                var view    = command.ViewEngines.FindView(command.Context, commandResult.ViewName);
                result = view.Render(commandResult.Model);
            }
            return(result);
        }
Beispiel #2
0
        private static object TryInvokeCommand(CommandSet command, MethodInfo methodInfo)
        {
            object result;

            try
            {
                result = methodInfo.Invoke(command.Command, new[] { command.Args });
            }
            catch (TargetInvocationException e)
            {
                throw e.InnerException;
            }
            return(result);
        }
Beispiel #3
0
        private static MethodInfo FindExecuteMethod(Type commandType, CommandSet command)
        {
            MethodInfo executeMethodInfo = null;

            IEnumerable <MethodInfo> methods =
                from method in commandType.GetMethods()
                where method.Name == ExecuteMethod
                select method;

            foreach (MethodInfo method in methods)
            {
                ParameterInfo[] parameters = method.GetParameters();
                foreach (var parameter in parameters)
                {
                    if (parameter.ParameterType == command.Args.GetType())
                    {
                        executeMethodInfo = method;
                        break;
                    }
                }
            }
            return(executeMethodInfo);
        }
Beispiel #4
0
 public CommandExecutable(string[] args, CommandType commandType, ArgumentMatcher argumentMatcher)
 {
     _commandType     = commandType;
     _argumentMatcher = argumentMatcher;
     _commandSet      = CreateCommandWithArgs(args, commandType);
 }