Esempio n. 1
0
        internal static void RunBootstrap(this IScriptExecutor executor, string moduleNamespace)
        {
            var script = GetBootstrapScript(moduleNamespace, includeStylesheets: true);

            if (script != null)
            {
                executor.RunScript("bootstrap", script);
            }
        }
Esempio n. 2
0
        private void Execute(PluginEnvironment environment, IScriptExecutor executor)
        {
            if (!plugins.Any(plugin => plugin.HasEnvironment(environment)) || !executor.RunFile($"plugins.{environment.GetPluginScriptFile()}"))
            {
                return;
            }

            bool includeDisabled = environment == PluginEnvironment.Browser;

            if (includeDisabled)
            {
                executor.RunScript("gen:pluginconfig", PluginScriptGenerator.GenerateConfig(Config));
            }

            List <string> errors = new List <string>(1);

            foreach (Plugin plugin in Plugins)
            {
                string path = plugin.GetScriptPath(environment);

                if (string.IsNullOrEmpty(path) || (!includeDisabled && !Config.IsEnabled(plugin)) || !plugin.CanRun)
                {
                    continue;
                }

                string script;

                try{
                    script = File.ReadAllText(path);
                }catch (Exception e) {
                    errors.Add($"{plugin.Identifier} ({Path.GetFileName(path)}): {e.Message}");
                    continue;
                }

                executor.RunScript($"plugin:{plugin}", PluginScriptGenerator.GeneratePlugin(plugin.Identifier, script, bridge.GetTokenFromPlugin(plugin), environment));
            }

            Executed?.Invoke(this, new PluginErrorEventArgs(errors));
        }
Esempio n. 3
0
 public static void RunFunction(this IScriptExecutor executor, string name, params object?[] args)
 {
     executor.RunScript("about:blank", GenerateJavaScriptFunctionCall(name, args));
 }