private void loadPlugins() { Console.WriteLine("Loading Plugins..."); var pluginTypes = PluginLoader.LoadPluginsFromFolders <ControllerPlugin>(Configuration.PluginFolders); var pluginInstances = PluginLoader.InstanciatePlugins <ControllerPlugin>(pluginTypes.Append(typeof(LocalRecordsProvider))).ToList(); Console.WriteLine(); ControllerPlugin manialinkDisplayManager = null; try { manialinkDisplayManager = pluginInstances.SingleOrDefault(plugin => typeof(IManialinkDisplayManager).IsAssignableFrom(plugin.GetType())); } catch { Console.WriteLine("Multiple custom Manialink Display Managers found, using default one."); } if (manialinkDisplayManager != null) { Console.WriteLine("Using custom Manialink Display Manager: " + PluginBase.GetName(manialinkDisplayManager.GetType()) + " (" + PluginBase.GetIdentifier(manialinkDisplayManager.GetType()) + ")"); ManialinkDisplayManager = (IManialinkDisplayManager)manialinkDisplayManager; } else { Console.WriteLine("No custom Manialink Display Manager found, using default one."); manialinkDisplayManager = new ManialinkDisplayManager(); if (manialinkDisplayManager.Load(this)) { pluginInstances.Add(manialinkDisplayManager); ManialinkDisplayManager = (IManialinkDisplayManager)manialinkDisplayManager; } } Console.WriteLine(); ControllerPlugin clientsManager = null; try { clientsManager = pluginInstances.SingleOrDefault(plugin => typeof(IClientsManager).IsAssignableFrom(plugin.GetType())); } catch { Console.WriteLine("Multiple custom Clients Managers found, using default one."); } if (clientsManager != null) { Console.WriteLine("Using custom Clients Manager: " + PluginBase.GetName(clientsManager.GetType()) + " (" + PluginBase.GetIdentifier(clientsManager.GetType()) + ")"); ClientsManager = (IClientsManager)clientsManager; } else { Console.WriteLine("No custom Clients Manager found, using default one."); clientsManager = new ClientsManager(); if (clientsManager.Load(this)) { pluginInstances.Add(clientsManager); ClientsManager = (IClientsManager)clientsManager; } } plugins = pluginInstances.Select(plugin => { Console.WriteLine(PluginBase.GetName(plugin.GetType()) + " ..."); var success = plugin.Load(this); Console.WriteLine(success ? "OK" : "Failed"); return(new { Plugin = plugin, Success = success }); }) .Where(loadedPlugin => loadedPlugin.Success) .Select(loadedPlugin => loadedPlugin.Plugin) .ToDictionary(plugin => PluginBase.GetIdentifier(plugin.GetType()).Replace(' ', '_').Replace('$', '_').ToLower()); Console.WriteLine("Completed Loading Plugins."); }