// Method used to get the available external plugins private async Task GetPlugins() { // Query the plugin factory to get a list of all the assemblies that contain an 'IScrobbleSource' class List <Plugin> typedPlugins = await PluginFactory.GetPluginsOfType(ApplicationUtility.ApplicationPath(), typeof(IScrobbleSource)).ConfigureAwait(false); // Local list of all the plugins ScrobbleFactory.ScrobblePlugins = new List <IScrobbleSource>(); // Track whether or not new plugins have been discovered and don't have associated enabled/disabled state in the // current user settings bool requiresSettingsToBeSaved = false; // Iterate each of the available plugins foreach (Plugin pluginItem in typedPlugins) { // Conver the plugin into the base type that we know about var pluginInstance = pluginItem.PluginInstance as IScrobbleSource; // Add this plugin to internal list ScrobbleFactory.ScrobblePlugins.Add(pluginInstance); // Check if we have any settings for this plugin if (Core.Settings.ScrobblerStatus.Count(item => item.Identifier == pluginInstance.SourceIdentifier) == 0) { // No? Add a default instance of the settings for this plugin, defaulting it to 'off' Core.Settings.ScrobblerStatus.Add(new LastFM.Common.Classes.ScrobblerSourceStatus() { Identifier = pluginInstance.SourceIdentifier, IsEnabled = false }); // Mark the fact that we need to update the users settings file requiresSettingsToBeSaved = true; } } // Create an instance of the iTunes Scrobble plugin and add it to the list ScrobbleFactory.ScrobblePlugins.Add(new iTunesScrobblePlugin()); // Create an instance of the Windows Media Player Scrobble plugin and add it to the list // and assign the host form for the Media Player interop control ScrobbleFactory.ScrobblePlugins.Add(new WindowsMediaScrobbleSource(_playerForm)); // If we need to update the users settings file if (requiresSettingsToBeSaved) { // Automatically save the settings file Core.SaveSettings(); } }