public void ExecutePlugins(IFrame frame, PluginEnvironment environment, bool includeDisabled) { if (includeDisabled) { ScriptLoader.ExecuteScript(frame, PluginScriptGenerator.GenerateConfig(Config), "gen:pluginconfig"); } List <string> failedPlugins = 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) { failedPlugins.Add(plugin.Identifier + " (" + Path.GetFileName(path) + "): " + e.Message); continue; } int token; if (tokens.ContainsValue(plugin)) { token = GetTokenFromPlugin(plugin); } else { token = GenerateToken(); tokens[token] = plugin; } ScriptLoader.ExecuteScript(frame, PluginScriptGenerator.GeneratePlugin(plugin.Identifier, script, token, environment), "plugin:" + plugin); } Executed?.Invoke(this, new PluginErrorEventArgs(failedPlugins)); }
public void ExecutePlugins(IFrame frame, PluginEnvironment environment) { if (!HasAnyPlugin(environment)) { return; } ScriptLoader.ExecuteScript(frame, PluginSetupScripts[environment], environment.GetScriptIdentifier()); ScriptLoader.ExecuteScript(frame, PluginSetupScripts[PluginEnvironment.None], PluginEnvironment.None.GetScriptIdentifier()); bool includeDisabled = environment.IncludesDisabledPlugins(); if (includeDisabled) { ScriptLoader.ExecuteScript(frame, PluginScriptGenerator.GenerateConfig(Config), "gen:pluginconfig"); } List <string> failedPlugins = 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) { failedPlugins.Add(plugin.Identifier + " (" + Path.GetFileName(path) + "): " + e.Message); continue; } ScriptLoader.ExecuteScript(frame, PluginScriptGenerator.GeneratePlugin(plugin.Identifier, script, GetTokenFromPlugin(plugin), environment), "plugin:" + plugin); } Executed?.Invoke(this, new PluginErrorEventArgs(failedPlugins)); }