1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-27 02:09:59 +00:00

Enum Config values retrieved properly

This commit is contained in:
Mark McDowall 2013-05-13 22:22:51 -07:00
parent 72ba7a4638
commit aea80870d3

View file

@ -87,16 +87,16 @@ public String SabTvCategory
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
{
get { return (SabPriorityType)GetValueInt("SabRecentTvPriority"); }
get { return GetValueEnum("SabRecentTvPriority", SabPriorityType.Default); }
set { SetValue("SabRecentTvPriority", (int)value); }
set { SetValue("SabRecentTvPriority", value); }
}
public String DownloadClientTvDirectory
@ -275,9 +275,9 @@ public Guid UGuid
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
@ -347,7 +347,6 @@ public int RssSyncInterval
set { SetValue("RssSyncInterval", value); }
}
public Boolean IgnoreArticlesWhenSortingSeries
{
get { return GetValueBoolean("IgnoreArticlesWhenSortingSeries", true); }
@ -399,16 +398,16 @@ public Int32 NzbgetPriority
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
{
get { return (PriorityType)GetValueInt("NzbgetRecentTvPriority"); }
get { return GetValueEnum("NzbgetRecentTvPriority", PriorityType.Normal); }
set { SetValue("NzbgetRecentTvPriority", (int)value); }
set { SetValue("NzbgetRecentTvPriority", value); }
}
public string NzbRestrictions
@ -438,6 +437,11 @@ private int GetValueInt(string key, int defaultValue = 0)
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)
{
EnsureCache();
@ -493,6 +497,11 @@ public void SetValue(string key, string value)
ClearCache();
}
public void SetValue(string key, Enum value)
{
SetValue(key, value.ToString().ToLower());
}
public void SaveValues(Dictionary<string, object> configValues)
{
var allWithDefaults = AllWithDefaults();