mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 18:57:39 -07:00
ConfigFile for NzbDrone.exe is now stored under App_Data for NzbDrone.Web. - This will be to provide the users a way to edit Port and set whether they want their default browser to open on startup, all form the WebUI (and not be overwritten on upgrades).
This commit is contained in:
parent
79472964ed
commit
f0f706b32c
9 changed files with 223 additions and 6 deletions
53
NzbDrone.Core/Providers/Core/ConfigFileProvider.cs
Normal file
53
NzbDrone.Core/Providers/Core/ConfigFileProvider.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Core
|
||||
{
|
||||
public class ConfigFileProvider
|
||||
{
|
||||
public string ConfigFile
|
||||
{
|
||||
get { return Path.Combine(CentralDispatch.AppPath, "App_Data", "Config.xml"); }
|
||||
}
|
||||
|
||||
public virtual int Port
|
||||
{
|
||||
get { return GetValueInt("Port"); }
|
||||
}
|
||||
|
||||
public virtual bool LaunchBrowser
|
||||
{
|
||||
get { return GetValueBoolean("LaunchBrowser"); }
|
||||
}
|
||||
|
||||
public virtual string GetValue(string key, string parent = null)
|
||||
{
|
||||
var xDoc = XDocument.Load(ConfigFile);
|
||||
var config = xDoc.Descendants("Config").Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
||||
if (parent != null)
|
||||
parentContainer = config.Descendants(parent).Single();
|
||||
|
||||
var value = parentContainer.Descendants(key).Single().Value;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public virtual int GetValueInt(string key, string parent = null)
|
||||
{
|
||||
return Convert.ToInt32(GetValue(key, parent));
|
||||
}
|
||||
|
||||
public virtual bool GetValueBoolean(string key, string parent = null)
|
||||
{
|
||||
return Convert.ToBoolean(GetValue(key, parent));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue