Manages script tags that hold DLR-based code.
Beispiel #1
0
 /// <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);
         });
     });
 }
 /// <summary>
 /// Gets and validates the entry-point.
 /// Pre-conditions:  entryPoint is the path to validate
 ///                  langConfig is the list of languages used to detect
 ///                  the entry point. scriptTags track the <script>
 ///                  blocks on the HTML page.
 /// Post-conditions: returns the name of the validated entry-point. The
 ///                  return value can be null if no valid entry-point
 ///                  exists while there exists a inline script-tag.
 ///                  The language of the entry-point is marked as "used"
 ///                  in langConfig.
 /// </summary>
 private static string GetAndValidateEntryPoint
     (string entryPoint, DynamicLanguageConfig langConfig, DynamicScriptTags scriptTags)
 {
     if (entryPoint == null)
     {
         entryPoint = FindEntryPoint(langConfig);
     }
     else
     {
         var vfs    = BrowserPAL.PAL.VirtualFilesystem;
         var stream = vfs.GetFile(entryPoint);
         if (stream == null)
         {
             throw new ApplicationException(
                       string.Format(
                           "Application expected to have an entry point called {0}, but was not found (check the {1})",
                           entryPoint, BrowserPAL.PAL.VirtualFilesystem.Name()));
         }
     }
     if (entryPoint != null)
     {
         var entryPointExt = Path.GetExtension(entryPoint);
         foreach (var lang in langConfig.Languages)
         {
             foreach (var ext in lang.Extensions)
             {
                 if (entryPointExt == ext)
                 {
                     langConfig.LanguagesUsed[lang.Names[0].ToLower()] = true;
                     break;
                 }
             }
         }
     }
     return(entryPoint);
 }
Beispiel #3
0
        /// <summary>
        /// Gets and validates the entry-point.
        /// Pre-conditions:  entryPoint is the path to validate
        ///                  langConfig is the list of languages used to detect
        ///                  the entry point. scriptTags track the <script> 
        ///                  blocks on the HTML page.
        /// Post-conditions: returns the name of the validated entry-point. The
        ///                  return value can be null if no valid entry-point 
        ///                  exists while there exists a inline script-tag.
        ///                  The language of the entry-point is marked as "used"
        ///                  in langConfig.
        /// </summary>
        private static string GetAndValidateEntryPoint
        (string entryPoint, DynamicLanguageConfig langConfig, DynamicScriptTags scriptTags) {
            if (entryPoint == null) {
                entryPoint = FindEntryPoint(langConfig);
            } else {
                var vfs = BrowserPAL.PAL.VirtualFilesystem;
                var stream = vfs.GetFile(entryPoint);
                if (stream == null) {
                    throw new ApplicationException(
                      string.Format(
"Application expected to have an entry point called {0}, but was not found (check the {1})", 
                        entryPoint, BrowserPAL.PAL.VirtualFilesystem.Name()));
                }
            }
            if(entryPoint != null) {
                var entryPointExt = Path.GetExtension(entryPoint);
                foreach (var lang in langConfig.Languages) {
                    foreach (var ext in lang.Extensions) {
                        if (entryPointExt == ext) {
                            langConfig.LanguagesUsed[lang.Names[0].ToLower()] = true;
                            break;
                        }
                    }
                }
            }
            return entryPoint;
        }
 /// <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);
             });
         });
     });
 }
Beispiel #5
0
 /// <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);
         });
     });
 }