Ejemplo n.º 1
0
    public static void Execute(int argc, string[] args, ref string output, GameConsoleHandler gameConsole)
    {
        ConsoleCommands.argc        = argc;
        ConsoleCommands.args        = args;
        ConsoleCommands.gameConsole = gameConsole;

        ConsoleCommands instance  = new ConsoleCommands(); // If only we would be able to program in a functional programming language!
        Type            thisType  = instance.GetType();
        MethodInfo      theMethod = thisType.GetMethod(args[0]);

        if (theMethod == null || args[0].Equals("Execute"))
        {
            foreach (string token in args)
            {
                output += token;
            }
            output += "\n ERROR: Unable to find command '" + args[0] + "'!";
            return;
        }
        output = theMethod.Invoke(instance, null) as string;
    }