protected override void OnPlaying(TimeSpan startTime, TimeSpan endTime) { base.OnPlaying(startTime, endTime); ScriptHostGenerator hostGenerator = new ScriptHostGenerator(); _scriptHost = hostGenerator.GenerateScript(this.Sequence as ScriptSequence); string[] errors = hostGenerator.Errors.ToArray(); OnMessage(new ExecutorMessageEventArgs(Sequence, string.Join(Environment.NewLine, errors))); // An end time < start time means compile only. if (endTime >= startTime) { if (errors.Length == 0) { // Under the current implementation, this results in a thread being spawned. // That thread is the actual execution path of their code. _scriptHost.Ended += (sender, e) => { EndTime = TimeSpan.Zero; }; _scriptHost.Error += (sender, e) => { OnError(e); }; _scriptHost.Start(); } else { throw new Exception("Script did not compile."); } } }
public void Compile(ScriptSequence sequence) { ScriptHostGenerator hostGenerator = new ScriptHostGenerator(); ScriptHost = hostGenerator.GenerateScript(sequence); Errors = hostGenerator.Errors.ToArray(); }
protected override void OnPlaying(TimeSpan startTime, TimeSpan endTime) { base.OnPlaying(startTime, endTime); ScriptHostGenerator hostGenerator = new ScriptHostGenerator(); _scriptHost = hostGenerator.GenerateScript(this.Sequence as ScriptSequence); string[] errors = hostGenerator.Errors.ToArray(); OnMessage(new ExecutorMessageEventArgs(Sequence, string.Join(Environment.NewLine, errors))); // An end time < start time means compile only. if(endTime >= startTime) { if(errors.Length == 0) { // Under the current implementation, this results in a thread being spawned. // That thread is the actual execution path of their code. _scriptHost.Ended += (sender, e) => { EndTime = TimeSpan.Zero; }; _scriptHost.Error += (sender, e) => { OnError(e); }; _scriptHost.Start(); } else { throw new Exception("Script did not compile."); } } }
private SourceFile _CreateSkeletonFile(string fileName) { // Setting the class name any time the skeleton file is generated so that when // the framework is generated, it will be part of the same class. string nameSpace = ScriptHostGenerator.UserScriptNamespace; ClassName = ScriptHostGenerator.Mangle(Name); SourceFile sourceFile = _CreateBlankFile(fileName); sourceFile.Contents = Language.SkeletonGenerator.Generate(nameSpace, ClassName); return(sourceFile); }
private SourceFile _CreateSkeletonFile(string fileName) { ScriptModuleManagement manager = Modules.GetManager <IScriptModuleInstance, ScriptModuleManagement>(); IScriptSkeletonGenerator skeletonFileGenerator = manager.GetSkeletonGenerator(Language); // Setting the class name any time the skeleton file is generated so that when // the framework is generated, it will be part of the same class. string nameSpace = ScriptHostGenerator.UserScriptNamespace; ClassName = ScriptHostGenerator.Mangle(Name); SourceFile sourceFile = _CreateBlankFile(fileName); sourceFile.Contents = skeletonFileGenerator.Generate(nameSpace, ClassName); return(sourceFile); }