public void Apply() { foreach (var plugin in Core.Plugins) { plugin.Value.Enabled = !DisabledPlugins.Contains(plugin.Key); } PluginManager.Core.Docking.Refresh(); if (UIStyle != null && StyleManager.Style != UIStyle) { StyleManager.Style = UIStyle; } }
/// <summary> /// Looks up Omea Plugin assembly files, loads them, instantiates the plugin classes, calls their <see cref="IPlugin.Register"/>, all on the calling thread. /// </summary> public void LoadPlugins() { var disabledplugins = new DisabledPlugins(); // Collect to get the full count for the progress before we start loading the DLLs/types var plugins = new List <PossiblyPluginFileInfo>(); foreach (PossiblyPluginFileInfo file in GetAllPluginFiles()) { if (!file.IsPlugin) { continue; // Need plugins only } // Disabled plugin? Check by the DLL name if (!disabledplugins.Contains(Path.GetFileNameWithoutExtension(file.File.FullName))) { plugins.Add(file); } } // Load! var progressWindow = (SplashScreen)Core.ProgressWindow; for (int nFile = 0; nFile < plugins.Count; nFile++) { if (progressWindow != null) { progressWindow.UpdateProgress((nFile + 1) * 100 / plugins.Count, Stringtable.LoadingPluginsProgressMessage, null); // Progress after the current file before we process it (at the beginning, accomodate for collecting the files; at the and, let see the 100% fill for some time) } // Try loading string sError; if (!LoadPlugins_LoadFile(plugins[nFile], out sError)) { // Failed, report the error _mapPluginLoadRuntimeErrors[plugins[nFile].File.FullName] = sError; // Overwrite old Core.ReportBackgroundException(new ApplicationException(sError)); // Disable the failed plugin? LoadPlugins_SuggestDisable(plugins[nFile].File, disabledplugins, sError, progressWindow); } else { _mapPluginLoadRuntimeErrors.Remove(plugins[nFile].File.FullName); // Clean the error record } } // Apply declarative plugin settings LoadPlugins_XmlConfiguration(); // Types without supporting plugins LoadPlugins_MarkUnloadedResourceTypes(); }
/// <summary> /// Checks if a given plugin is disabled. /// </summary> /// <param name="meta">the plugin to check</param> /// <returns><see langword="true"/> if the plugin is disabled, <see langword="false"/> otherwise.</returns> public static bool IsDisabled(PluginMetadata meta) => DisabledPlugins.Contains(meta);