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."); } } }
protected override void OnSequenceStarted(SequenceStartedEventArgs e) { if (!(Sequence is ScriptSequence)) { throw new InvalidOperationException("Attempt to compile a non-script sequence."); } Sequence.SequenceData.EffectData.Clear(); ScriptCompiler compiler = new ScriptCompiler(); compiler.Compile((ScriptSequence)Sequence); OnMessage(new ExecutorMessageEventArgs(Sequence, string.Join(Environment.NewLine, compiler.Errors))); if (!compiler.HasErrors) { if (!_CompileOnly(e)) { _scriptHost = compiler.ScriptHost; _StartScript(); } } else { throw new Exception("Script did not compile."); } base.OnSequenceStarted(e); }
private void _StopScript() { if(_scriptHost != null) { _scriptHost.Stop(); _scriptHost = null; } }
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 void _StopScript() { if (_scriptHost != null) { _scriptHost.Stop(); _scriptHost = null; } }
private void _ScriptEnded(object sender, EventArgs e) { //I'm sure there's an undocumented reason for this that I need to document. EndTime = TimeSpan.Zero; _scriptHost.Ended -= _ScriptEnded; _scriptHost.Error -= _ScriptError; _scriptHost = null; }
protected override void OnSequenceStarted(SequenceStartedEventArgs e) { if (!(Sequence is ScriptSequence)) throw new InvalidOperationException("Attempt to compile a non-script sequence."); Sequence.SequenceData.EffectData.Clear(); ScriptCompiler compiler = new ScriptCompiler(); compiler.Compile((ScriptSequence) Sequence); OnMessage(new ExecutorMessageEventArgs(Sequence, string.Join(Environment.NewLine, compiler.Errors))); if (!compiler.HasErrors) { if (!_CompileOnly(e)) { _scriptHost = compiler.ScriptHost; _StartScript(); } } else { throw new Exception("Script did not compile."); } base.OnSequenceStarted(e); }
public void Compile(ScriptSequence sequence) { ScriptHostGenerator hostGenerator = new ScriptHostGenerator(); ScriptHost = hostGenerator.GenerateScript(sequence); Errors = hostGenerator.Errors.ToArray(); }