public MediaAccessConfiguration() { try { XElement file = XElement.Load(Configuration.GetPath("MediaAccess.xml")); DefaultPlugins = new DefaultPluginConfiguration() { Filesystem = file.Element("defaultPlugins").Element("filesystem").Value, Movie = file.Element("defaultPlugins").Element("movie").Value, Music = file.Element("defaultPlugins").Element("music").Value, Picture = file.Element("defaultPlugins").Element("picture").Value, TVShow = file.Element("defaultPlugins").Element("tvshow").Value, }; DisabledPlugins = file.Element("disabledPlugins").Elements("disabled").Select(x => x.Value).ToList(); PluginConfiguration = new Dictionary<string, List<PluginConfigItem>>(); foreach (XElement plugin in file.Element("pluginConfiguration").Elements("plugin")) { PluginConfiguration[plugin.Attribute("name").Value] = plugin.Elements().Select(x => new PluginConfigItem() { DisplayName = x.Attribute("displayname").Value, Name = x.Name.LocalName, Type = (ConfigType)Enum.Parse(typeof(ConfigType), x.Attribute("type").Value, true), Value = PerformFolderSubstitution(x.Value), }).ToList(); } } catch (Exception ex) { Log.Error("Failed to load MediaAccess configuration", ex); } }
public MediaAccessConfiguration() { try { XElement file = XElement.Load(Configuration.GetPath("MediaAccess.xml")); DefaultPlugins = new DefaultPluginConfiguration() { Filesystem = file.Element("defaultPlugins").Element("filesystem").Value, Movie = file.Element("defaultPlugins").Element("movie").Value, Music = file.Element("defaultPlugins").Element("music").Value, Picture = file.Element("defaultPlugins").Element("picture").Value, TVShow = file.Element("defaultPlugins").Element("tvshow").Value, }; DisabledPlugins = file.Element("disabledPlugins").Elements("disabled").Select(x => x.Value).ToList(); PluginConfiguration = new Dictionary <string, List <PluginConfigItem> >(); foreach (XElement plugin in file.Element("pluginConfiguration").Elements("plugin")) { PluginConfiguration[plugin.Attribute("name").Value] = new List <PluginConfigItem>(); foreach (var x in plugin.Elements()) { ConfigType type = (ConfigType)Enum.Parse(typeof(ConfigType), x.Attribute("type").Value, true); string value = type == ConfigType.File || type == ConfigType.Folder ? PerformFolderSubstitution(x.Value) : x.Value; PluginConfiguration[plugin.Attribute("name").Value].Add(new PluginConfigItem() { DisplayName = x.Attribute("displayname").Value, Name = x.Name.LocalName, Type = type, Value = value }); } } } catch (Exception ex) { Log.Error("Failed to load MediaAccess configuration", ex); } }