Ejemplo n.º 1
0
        public static List <String> compileAllFilesIndividually(List <String> filesToCompile, O2Thread.FuncVoidT1 <string> currentTask, O2Thread.FuncVoidT1 <int> numberOfStepsToPerform, O2Thread.FuncVoid onStepEvent)
        {
            currentTask("Compiling all rules individualy (one file at the time)");
            numberOfStepsToPerform(filesToCompile.Count);
            var compileEngine = new CompileEngine();

            PublicDI.log.info("Compiling All XRules source code files ONE at the time");
            var results = new List <String>();

            foreach (var fileToCompile in filesToCompile)
            {
                var assembly = compileEngine.compileSourceFile(fileToCompile);

                if (assembly != null)
                {
                    results.Add(assembly.Location);
                }
                else
                {
                    PublicDI.log.error("In XRules_Execution.compileAllFilesIndividually, could not compile file: {0}", fileToCompile);
                }
                onStepEvent();
            }
            return(results);
        }
Ejemplo n.º 2
0
        public Assembly compileScript(string o2Script)
        {
            var compileEngine = new CompileEngine();
            var assembly      = compileEngine.compileSourceFile(o2Script.local());

            if (assembly.isNull())
            {
                MessageBox.Show(compileEngine.sbErrorMessage.str(), @"Compilation error in Start_O2:");
            }
            return(assembly);
        }
        public bool injectIntoProcess(Process process, bool x64, bool runtime40, string sourceCodeFile)
        {
            //fixedCourceCode.showInCodeViewer();
            var compileEngine = new CompileEngine(runtime40 ? "v4.0" : "v3.5")
            {
                useCachedAssemblyIfAvailable = false
            };
            //var compiledAssembly = compileEngine.compileSourceCode(fixedCourceCode);
            var compiledAssembly = compileEngine.compileSourceFile(sourceCodeFile);

            return(injectIntoProcess(process, x64, runtime40, compiledAssembly));
        }
Ejemplo n.º 4
0
        public static Assembly  compileCodeSnippet(this string snippet, Action <string> onCompileOk, Action <string> onCompileFail)
        {
            try
            {
                var codeFile = createCSharpFileFromCodeSnippet(snippet);

                var compileEngine = new CompileEngine();
                var assembly      = compileEngine.compileSourceFile(codeFile);
                if (assembly.notNull())
                {
                    onCompileOk("[compileAndExecuteCodeSnippet] Snippet assembly created OK: {0}".format(assembly.location()));
                    return(assembly);
                }
                onCompileFail("[compileAndExecuteCodeSnippet] Compilation failed: ".line() + compileEngine.sbErrorMessage.str());
            }
            catch (Exception ex)
            {
                ex.log("[compileAndExecuteCodeSnippet]");
            }
            return(null);
        }
Ejemplo n.º 5
0
        public void onCompileScript(IStep step)
        {
            O2Thread.mtaThread(
                () =>
            {
                step.clear();
                //var panel = step.FirstControl;
                step.add_Label("Compiling Script:" + scriptToExecute);

                var compileEngine    = new CompileEngine();
                var compiledAssembly = compileEngine.compileSourceFile(scriptToExecute);
                if (compiledAssembly != null)
                {
                    var label       = step.add_Label("Compilation was ok", 20);
                    label.ForeColor = Color.DarkGreen;
                    step.add_Label("Which method to you want to execute?", 40);
                    var top = 40;
                    foreach (var method in PublicDI.reflection.getMethods(compiledAssembly))
                    {
                        if (PublicDI.reflection.getParameters(method).Count == 0 &&
                            method.Name.Contains(">b") == false)
                        {
                            var methodToExecute             = method;
                            step.add_Link(method.Name, top += 20, 10,
                                          () => PublicDI.reflection.invoke(methodToExecute));
                        }
                        ;
                    }
                }
                else
                {
                    var label       = step.add_Label("Compilation Failed", 20);
                    label.ForeColor = Color.DarkRed;
                    step.add_Label(compileEngine.sbErrorMessage.ToString(), 40);
                }
            });
        }