Enum Config values retrieved properly

pull/6/head
Mark McDowall 12 years ago
parent 72ba7a4638
commit aea80870d3

@ -87,16 +87,16 @@ namespace NzbDrone.Core.Configuration
public SabPriorityType SabBacklogTvPriority public SabPriorityType SabBacklogTvPriority
{ {
get { return (SabPriorityType)GetValueInt("SabBacklogTvPriority"); } get { return GetValueEnum("SabBacklogTvPriority", SabPriorityType.Default); }
set { SetValue("SabBacklogTvPriority", (int)value); } set { SetValue("SabBacklogTvPriority", value); }
} }
public SabPriorityType SabRecentTvPriority public SabPriorityType SabRecentTvPriority
{ {
get { return (SabPriorityType)GetValueInt("SabRecentTvPriority"); } get { return GetValueEnum("SabRecentTvPriority", SabPriorityType.Default); }
set { SetValue("SabRecentTvPriority", (int)value); } set { SetValue("SabRecentTvPriority", value); }
} }
public String DownloadClientTvDirectory public String DownloadClientTvDirectory
@ -275,9 +275,9 @@ namespace NzbDrone.Core.Configuration
public DownloadClientType DownloadClient public DownloadClientType DownloadClient
{ {
get { return (DownloadClientType)GetValueInt("DownloadClient"); } get { return GetValueEnum("DownloadClientType", DownloadClientType.Sabnzbd); }
set { SetValue("DownloadClient", (int)value); } set { SetValue("DownloadClient", value); }
} }
public string BlackholeDirectory public string BlackholeDirectory
@ -347,7 +347,6 @@ namespace NzbDrone.Core.Configuration
set { SetValue("RssSyncInterval", value); } set { SetValue("RssSyncInterval", value); }
} }
public Boolean IgnoreArticlesWhenSortingSeries public Boolean IgnoreArticlesWhenSortingSeries
{ {
get { return GetValueBoolean("IgnoreArticlesWhenSortingSeries", true); } get { return GetValueBoolean("IgnoreArticlesWhenSortingSeries", true); }
@ -399,16 +398,16 @@ namespace NzbDrone.Core.Configuration
public PriorityType NzbgetBacklogTvPriority public PriorityType NzbgetBacklogTvPriority
{ {
get { return (PriorityType)GetValueInt("NzbgetBacklogTvPriority"); } get { return GetValueEnum("NzbgetBacklogTvPriority", PriorityType.Normal); }
set { SetValue("NzbgetBacklogTvPriority", (int)value); } set { SetValue("NzbgetBacklogTvPriority", value); }
} }
public PriorityType NzbgetRecentTvPriority public PriorityType NzbgetRecentTvPriority
{ {
get { return (PriorityType)GetValueInt("NzbgetRecentTvPriority"); } get { return GetValueEnum("NzbgetRecentTvPriority", PriorityType.Normal); }
set { SetValue("NzbgetRecentTvPriority", (int)value); } set { SetValue("NzbgetRecentTvPriority", value); }
} }
public string NzbRestrictions public string NzbRestrictions
@ -438,6 +437,11 @@ namespace NzbDrone.Core.Configuration
return Convert.ToInt32(GetValue(key, defaultValue)); return Convert.ToInt32(GetValue(key, defaultValue));
} }
public T GetValueEnum<T>(string key, T defaultValue)
{
return (T)Enum.Parse(typeof(T), GetValue(key, defaultValue), true);
}
public string GetValue(string key, object defaultValue, bool persist = false) public string GetValue(string key, object defaultValue, bool persist = false)
{ {
EnsureCache(); EnsureCache();
@ -493,6 +497,11 @@ namespace NzbDrone.Core.Configuration
ClearCache(); ClearCache();
} }
public void SetValue(string key, Enum value)
{
SetValue(key, value.ToString().ToLower());
}
public void SaveValues(Dictionary<string, object> configValues) public void SaveValues(Dictionary<string, object> configValues)
{ {
var allWithDefaults = AllWithDefaults(); var allWithDefaults = AllWithDefaults();

Loading…
Cancel
Save