Example #1
0
        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.");
                }
            }
        }
Example #2
0
        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);
        }
Example #3
0
 private void _StopScript()
 {
     if(_scriptHost != null) {
         _scriptHost.Stop();
         _scriptHost = null;
     }
 }
Example #4
0
        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.");
                }
            }
        }
Example #5
0
 private void _StopScript()
 {
     if (_scriptHost != null)
     {
         _scriptHost.Stop();
         _scriptHost = null;
     }
 }
Example #6
0
 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;
 }
Example #7
0
 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;
 }
Example #8
0
        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();
 }