/// <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(); }