/// <summary> /// Runs the registered script tags against the DynamicEngine. /// </summary> public void Run(DynamicEngine engine) { var inlineScope = engine.CreateScope(); foreach (var sc in Code) { engine.Engine = _LangConfig.GetEngine(sc.Language); if (engine.Engine != null && !sc.Defer) { ScriptSource sourceCode = null; ScriptScope scope = null; if (sc.External != null) { var code = BrowserPAL.PAL.VirtualFilesystem.GetFileContents(sc.External); if (code == null) { continue; } sourceCode = engine.Engine.CreateScriptSourceFromString( code, DynamicApplication.BaseUri.MakeRelativeUri(sc.External).ToString(), SourceCodeKind.File ); scope = engine.CreateScope(); } else if (sc.Inline != null) { Assert.NotNull(DynamicApplication.HtmlPageUri); var page = BrowserPAL.PAL.VirtualFilesystem.GetFileContents(DynamicApplication.HtmlPageUri); var code = AlignSourceLines(sc.Inline, page); sourceCode = engine.Engine.CreateScriptSourceFromString( RemoveMargin(code), DynamicApplication.HtmlPageUri.ToString(), SourceCodeKind.File ); scope = inlineScope; } if (sourceCode != null && scope != null) { RunningScriptTags = true; sourceCode.Compile(new ErrorFormatter.Sink()).Execute(scope); RunningScriptTags = false; } } } }
/// <summary> /// Runs the registered script tags against the DynamicEngine. /// </summary> public void Run(DynamicEngine engine) { var inlineScope = engine.CreateScope(); foreach (var sc in Code) { engine.Engine = _LangConfig.GetEngine(sc.Language); if (engine.Engine != null && !sc.Defer) { ScriptSource sourceCode = null; ScriptScope scope = null; if (sc.External != null) { var code = BrowserPAL.PAL.VirtualFilesystem.GetFileContents(sc.External); if (code == null) { continue; } sourceCode = engine.Engine.CreateScriptSourceFromString( code, sc.External.AbsoluteUri, SourceCodeKind.File ); scope = engine.CreateScope(); } else if (sc.Inline != null) { sourceCode = engine.Engine.CreateScriptSourceFromString( sc.Inline, "main" + engine.LangConfig.GetLanguageByName(sc.Language).Extensions[0], SourceCodeKind.File ); scope = inlineScope; } if (sourceCode != null && scope != null) { RunningScriptTags = true; sourceCode.Compile(new ErrorFormatter.Sink()).Execute(scope); RunningScriptTags = false; } } } }
/// <summary> /// Starts the dynamic application /// </summary> void DynamicApplication_Startup(object sender, StartupEventArgs e) { Settings.Parse(InitParams = NormalizeInitParams(e.InitParams)); ScriptTags = new DynamicScriptTags(LanguagesConfig); XamlScriptTags.Load(); LanguagesConfig.DownloadLanguages(AppManifest, () => { ScriptTags.DownloadExternalCode(() => { Engine = new DynamicEngine(); if (Settings.ConsoleEnabled && LanguagesConfig.LanguagesUsed.Count > 0) { Console = Repl.Show(); } LanguageTypeExtensions.Load(Engine.LangConfig); ScriptTags.Run(Engine); Engine.Run(Settings.EntryPoint); }); }); }
public static ScriptRuntimeSetup CreateRuntimeSetup(List <Assembly> assemblies) { return(DynamicEngine.CreateRuntimeSetup(assemblies)); }
public static void LoadDefaultAssemblies(ScriptRuntime runtime) { DynamicEngine.LoadDefaultAssemblies(runtime); }
public static ScriptRuntimeSetup CreateRuntimeSetup() { return(DynamicEngine.CreateRuntimeSetup()); }
void DynamicApplication_Startup(object sender, StartupEventArgs e) { Settings.Parse(InitParams = NormalizeInitParams(e.InitParams)); Engine = new DynamicEngine(); AppManifest = new DynamicAppManifest(); AppManifest.LoadAssemblies(() => Engine.Start()); }
/// <summary> /// Starts the dynamic application /// </summary> void DynamicApplication_Startup(object sender, StartupEventArgs e) { Settings.Parse(InitParams = NormalizeInitParams(e.InitParams)); ScriptTags = new DynamicScriptTags(LanguagesConfig); ScriptTags.DownloadHtmlPage(() => { ScriptTags.FetchScriptTags(); XamlScriptTags.Load(); LanguagesConfig.DownloadLanguages(AppManifest, () => { ScriptTags.DownloadExternalCode(() => { Engine = new DynamicEngine(); if (HtmlPage.IsEnabled && Settings.ConsoleEnabled && LanguagesConfig.LanguagesUsed.Count > 0) Console = Repl.Show(); LanguageTypeExtensions.Load(Engine.LangConfig); if (HtmlPage.IsEnabled) ScriptTags.Run(Engine); Engine.Run(Settings.EntryPoint); }); }); }); }
/// <summary> /// Runs the registered script tags against the DynamicEngine. /// </summary> public void Run(DynamicEngine engine) { var inlineScope = engine.CreateScope(); foreach (var sc in Code) { engine.Engine = _LangConfig.GetEngine(sc.Language); if (engine.Engine != null && !sc.Defer) { ScriptSource sourceCode = null; ScriptScope scope = null; if(sc.External != null) { var code = BrowserPAL.PAL.VirtualFilesystem.GetFileContents(sc.External); if (code == null) continue; sourceCode = engine.Engine.CreateScriptSourceFromString( code, DynamicApplication.BaseUri.MakeRelativeUri(sc.External).ToString(), SourceCodeKind.File ); scope = engine.CreateScope(); } else if (sc.Inline != null) { Assert.NotNull(DynamicApplication.HtmlPageUri); var page = BrowserPAL.PAL.VirtualFilesystem.GetFileContents(DynamicApplication.HtmlPageUri); var code = AlignSourceLines(sc.Inline, page); sourceCode = engine.Engine.CreateScriptSourceFromString( RemoveMargin(code), DynamicApplication.HtmlPageUri.ToString(), SourceCodeKind.File ); scope = inlineScope; } if (sourceCode != null && scope != null) { RunningScriptTags = true; sourceCode.Compile(new ErrorFormatter.Sink()).Execute(scope); RunningScriptTags = false; } } } }
/// <summary> /// Runs the registered script tags against the DynamicEngine. /// </summary> public void Run(DynamicEngine engine) { var inlineScope = engine.CreateScope(); foreach (var sc in Code) { engine.Engine = _LangConfig.GetEngine(sc.Language); if (engine.Engine != null && !sc.Defer) { ScriptSource sourceCode = null; ScriptScope scope = null; if(sc.External != null) { var code = BrowserPAL.PAL.VirtualFilesystem.GetFileContents(sc.External); if (code == null) continue; sourceCode = engine.Engine.CreateScriptSourceFromString( code, sc.External.AbsoluteUri, SourceCodeKind.File ); scope = engine.CreateScope(); } else if (sc.Inline != null) { sourceCode = engine.Engine.CreateScriptSourceFromString( sc.Inline, "main" + engine.LangConfig.GetLanguageByName(sc.Language).Extensions[0], SourceCodeKind.File ); scope = inlineScope; } if (sourceCode != null && scope != null) { RunningScriptTags = true; sourceCode.Compile(new ErrorFormatter.Sink()).Execute(scope); RunningScriptTags = false; } } } }
/// <summary> /// Runs the registered script tags against the DynamicEngine. /// </summary> public void Run(DynamicEngine engine) { foreach (var pair in Code) { var lang = pair.Key; engine.Engine = _LangConfig.GetEngine(GetLanguageNameFrom(pair.Key)); if (engine.Engine != null) { foreach (var pair2 in pair.Value) { var defer = pair2.Key; var scripts = pair2.Value; if (!defer) { foreach (var uri in scripts.External) { var code = BrowserPAL.PAL.VirtualFilesystem.GetFileContents(uri); if (code == null) continue; ScriptSource externalSourceCode = engine.Engine.CreateScriptSourceFromString( code, uri.AbsoluteUri, SourceCodeKind.File ); externalSourceCode.Compile(new ErrorFormatter.Sink()).Execute(engine.EntryPointScope); } foreach (var code in scripts.Inline) { ScriptSource inlineSourceCode = engine.Engine.CreateScriptSourceFromString( code, HtmlPage.Document.DocumentUri.LocalPath.Remove(0, 1), SourceCodeKind.File ); inlineSourceCode.Compile(new ErrorFormatter.Sink()).Execute(engine.EntryPointScope); } } } } } }
/// <summary> /// Starts the dynamic application /// </summary> void DynamicApplication_Startup(object sender, StartupEventArgs e) { Settings.Parse(InitParams = NormalizeInitParams(e.InitParams)); ScriptTags = new DynamicScriptTags(LanguagesConfig); XamlScriptTags.Load(); LanguagesConfig.DownloadLanguages(AppManifest, () => { ScriptTags.DownloadExternalCode(() => { Engine = new DynamicEngine(); if (Settings.ConsoleEnabled) Repl.Show(); ScriptTags.Run(Engine); Engine.Run(Settings.EntryPoint); }); }); }