Beispiel #1
0
 public ExecState(ScriptControlVM vm, Dispatcher dispatcher, CancellationTokenSource cts)
 {
     this.CancellationTokenSource = cts;
     this.CancellationToken       = cts.Token;
     this.Globals        = new ScriptGlobals(vm, dispatcher, CancellationToken);
     this.IsInitializing = true;
 }
Beispiel #2
0
 void IScriptGlobalsHelper.Write(ScriptGlobals globals, List <ColorAndText> list)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     ReplEditor.OutputPrint(list.Select(a => new ColorAndText(a.Color, a.Text)));
 }
Beispiel #3
0
 void IScriptGlobalsHelper.Print(ScriptGlobals globals, CachedWriter writer, object color, Exception ex)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     writer.Write(Format(ex), color);
 }
Beispiel #4
0
 void IScriptGlobalsHelper.Print(ScriptGlobals globals, CachedWriter writer, object color, PrintOptionsImpl printOptions, object value)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     ObjectOutput(writer, color, printOptions, value);
 }
Beispiel #5
0
 void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, object color, Exception ex)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     ReplEditor.OutputPrintLine(Format(ex), color);
 }
Beispiel #6
0
 void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, object color, PrintOptionsImpl printOptions, object value)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     ObjectOutputLine(color, printOptions, value);
 }
Beispiel #7
0
 void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, object color, string text)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     ReplEditor.OutputPrintLine(text, color);
 }
Beispiel #8
0
 void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, object value)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     replEditor.OutputPrintLine(Format(value));
 }
Beispiel #9
0
 void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, string text)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     replEditor.OutputPrintLine(text);
 }
Beispiel #10
0
 void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, Exception ex)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     replEditor.OutputPrintLine(Format(ex));
 }
Beispiel #11
0
 void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, PrintOptionsImpl printOptions, object value)
 {
     if (!IsCurrentScript(globals))
     {
         return;
     }
     replEditor.OutputPrintLine(Format(value, printOptions.RoslynPrintOptions));
 }
Beispiel #12
0
 /// <summary>
 /// Returns true if it's the current script
 /// </summary>
 /// <param name="globals">Globals</param>
 /// <returns></returns>
 bool IsCurrentScript(ScriptGlobals globals) => execState?.Globals == globals;
Beispiel #13
0
 public CachedWriter(ScriptGlobals owner)
 {
     this.owner   = owner;
     PrintOptions = owner.PrintOptionsImpl.Clone();
     cachedList   = new List <ColorAndText>();
 }
Beispiel #14
0
        /// <summary>
        /// Returns true if it's the current script
        /// </summary>
        /// <param name="globals">Globals</param>
        /// <returns></returns>
        bool IsCurrentScript(ScriptGlobals globals)
        {
            var es = execState;

            return(es != null && es.Globals == globals);
        }