Example #1
0
        private static string getMethodName(string arg0)
        {
            string[] splittedArg0 = arg0.Split('!');
            switch (splittedArg0.Length)
            {
            case 2:
                string file       = splittedArg0[0];
                string methodName = splittedArg0[1];
                O2Cmd.log.write("Trying to load file {0} and execute method {1}", file, methodName);
                switch (Path.GetExtension(file))
                {
                case ".cs":
                    O2Cmd.log.write("\n*.cs file provided, compiling code\n");
                    Assembly assembly = new CompileEngine().compileSourceFile(file);
                    if (assembly == null)
                    {
                        O2Cmd.log.write("Error: could not compile provided code");
                    }
                    else
                    {
                        O2Cmd.log.write("Source code successfully compiled, loading types\n");
                        foreach (Type typeToLoad in assembly.GetTypes())
                        {
                            O2CmdApi.typesWithCommands.Add(typeToLoad);
                        }
                        O2Cmd.log.write("\nHere is the updated list of available command line methods\n");
                        O2Cmd.help();
                        O2Cmd.log.write("\nExecuting method:{0}\n", methodName);
                        return(methodName);
                    }
                    break;

                case ".dll":
                    break;

                default:
                    O2Cmd.log.error("ERROR: unsupported file extension (it must be *.cs or *.dll");
                    break;
                }
                return("");

            default:
                return(arg0);
            }
            //return arg0;
        }