private List <string> RunScript(CDS.CSharpScripting.CompiledScript compiledScript)
        {
            List <string> result = null;

            runtimeOutput.CDSWriteLine("* Running script *");

            using (var console = new CDS.CSharpScripting.ConsoleOutputHook(msg => runtimeOutput.CDSWrite(msg)))
            {
                try
                {
                    result = CDS.CSharpScripting.ScriptRunner.Run <List <string> >(
                        compiledScript: compiledScript,
                        globals: null);
                }
                catch (Exception exception)
                {
                    Common.SendExceptionToOutput(
                        runtimeOutput,
                        "Exception caught while running the script",
                        exception);
                }
            }

            runtimeOutput.CDSWriteLine("* Script run complete *");

            return(result);
        }
        private void CompileScript()
        {
            output.CDSWriteLine("* Compiling *");

            compiledScript = CDS.CSharpScripting.ScriptCompiler.Compile <List <string> >(
                script: csharpEditor.CDSScript);

            Common.DisplayCompilationOutput(output, compiledScript);

            output.CDSWriteLine("* Compilation done *");
        }
Exemple #3
0
        private void RunScript(CDS.CSharpScripting.CompiledScript compiledScript)
        {
            runtimeOutput.CDSWriteLine("* Running script *");

            using (var console = new CDS.CSharpScripting.ConsoleOutputHook(msg => runtimeOutput.CDSWrite(msg)))
            {
                try
                {
                    CDS.CSharpScripting.ScriptRunner.Run(
                        compiledScript: compiledScript,
                        globals: globals);

                    runtimeOutput.CDSWriteLine($"* Script run is complete: the new value of Animal is [{globals.Animal}] *");
                }
                catch (Exception exception)
                {
                    Common.SendExceptionToOutput(
                        runtimeOutput,
                        "Exception caught while running the script",
                        exception);
                }
            }
        }
 private void csharpEditor_CDSScriptChanged(object sender, EventArgs e)
 {
     compiledScript = null;
 }