support alias as default source
This commit is contained in:
parent
a7ea749d2c
commit
51dcb39c93
1 changed files with 27 additions and 3 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace isn
|
namespace isn
|
||||||
{
|
{
|
||||||
|
|
@ -10,10 +12,32 @@ namespace isn
|
||||||
|
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
public string DataProtectionTitle {get; set; }
|
public string DataProtectionTitle { get; set; }
|
||||||
public Dictionary<string, SourceSettings> Sources { get; set; }
|
public Dictionary<string, SourceSettings> Sources { get; set; }
|
||||||
|
|
||||||
public bool AutoUpdateApiKey { get; set; } = false;
|
public bool AutoUpdateApiKey { get; set; } = false;
|
||||||
public string DefaultSource { get; set; }
|
|
||||||
|
private string source;
|
||||||
|
/// <summary>
|
||||||
|
/// Default Url or alias for the source
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public string DefaultSource
|
||||||
|
{
|
||||||
|
get => source;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (Sources.ContainsKey(value))
|
||||||
|
{
|
||||||
|
source = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Sources.Values.Any(s => s.Alias == value))
|
||||||
|
{
|
||||||
|
source = Sources[value].Alias;
|
||||||
|
}
|
||||||
|
throw new InvalidOperationException("Add it to Sources before, with an API key, as source or alias .");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue