/// <summary> /// Makes sure that the Load Order is set for each plugin that is installed. /// </summary> private static void PluginManager_AfterRegisterHost(RegisterHostEventArgs eventArgs) { List <string> lst = GetLoadOrderList(LoadOrderQueue.Default); List <string> l = ListHelper.LoadList(PluginPaths.GlobalPluginListFile) .Select(x => x.Split(StaticData.KeyPairSeparator).First()).ToList(); lst.AddRange(l.Where(x => !lst.Contains(x))); SetLoadOrderList(LoadOrderQueue.Default, lst); }
/// <summary> /// Loads all compatible Plugins that are installed in the system. /// </summary> /// <param name="host">The Host that the Plugins need to be Compatible to</param> public static void LoadPlugins(IPluginHost host, bool addPlugins = true) { if (!IsInitialized) { throw new Exception("Can not use the plugin System when its not initialized."); } bool contains = LoadedPlugins.ContainsKey(host); if (contains && !addPlugins) { return; } if (!contains) { RegisterHostEventArgs args = new RegisterHostEventArgs(host, true); OnRegisterHost?.Invoke(args); if (args.Cancel) { return; } LoadedPlugins.Add(host, new List <IPlugin>()); } if (addPlugins) { SendLog($"Adding Plugins for {host.GetType().Name}"); List <PluginAssemblyPointer> ptrs = LoadFromList(PluginPaths.PluginListFile, host); LoadOrder.SortList(ptrs); ptrs.ForEach(AddFromLoaderResult); SendLog($"Added Plugins from {ptrs.Count} Packages"); } AfterRegisterHost?.Invoke(new RegisterHostEventArgs(host, false)); SendLogDivider(); }