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; }
void IScriptGlobalsHelper.Write(ScriptGlobals globals, List <ColorAndText> list) { if (!IsCurrentScript(globals)) { return; } ReplEditor.OutputPrint(list.Select(a => new ColorAndText(a.Color, a.Text))); }
void IScriptGlobalsHelper.Print(ScriptGlobals globals, CachedWriter writer, object color, Exception ex) { if (!IsCurrentScript(globals)) { return; } writer.Write(Format(ex), color); }
void IScriptGlobalsHelper.Print(ScriptGlobals globals, CachedWriter writer, object color, PrintOptionsImpl printOptions, object value) { if (!IsCurrentScript(globals)) { return; } ObjectOutput(writer, color, printOptions, value); }
void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, object color, Exception ex) { if (!IsCurrentScript(globals)) { return; } ReplEditor.OutputPrintLine(Format(ex), color); }
void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, object color, PrintOptionsImpl printOptions, object value) { if (!IsCurrentScript(globals)) { return; } ObjectOutputLine(color, printOptions, value); }
void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, object color, string text) { if (!IsCurrentScript(globals)) { return; } ReplEditor.OutputPrintLine(text, color); }
void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, object value) { if (!IsCurrentScript(globals)) { return; } replEditor.OutputPrintLine(Format(value)); }
void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, string text) { if (!IsCurrentScript(globals)) { return; } replEditor.OutputPrintLine(text); }
void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, Exception ex) { if (!IsCurrentScript(globals)) { return; } replEditor.OutputPrintLine(Format(ex)); }
void IScriptGlobalsHelper.PrintLine(ScriptGlobals globals, PrintOptionsImpl printOptions, object value) { if (!IsCurrentScript(globals)) { return; } replEditor.OutputPrintLine(Format(value, printOptions.RoslynPrintOptions)); }
/// <summary> /// Returns true if it's the current script /// </summary> /// <param name="globals">Globals</param> /// <returns></returns> bool IsCurrentScript(ScriptGlobals globals) => execState?.Globals == globals;
public CachedWriter(ScriptGlobals owner) { this.owner = owner; PrintOptions = owner.PrintOptionsImpl.Clone(); cachedList = new List <ColorAndText>(); }
/// <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); }