how about don't clear out the aliases? now I can configure more aliases
All checks were successful
gitea/vassago/pipeline/head This commit looks good

This commit is contained in:
Adam R Grey 2023-12-05 23:57:21 -05:00
parent 894b536c04
commit 451ace753d

View File

@ -57,18 +57,21 @@ namespace vassago.Conversion
if(currencyConf != null)
{
knownConversions.RemoveAll(kc => kc.Item1 == currencyConf.Base);
knownAliases.Remove(knownAliases.FirstOrDefault(kvp => kvp.Value == currencyConf.Base).Key);
foreach (var rate in currencyConf.rates)
knownAliases.Remove(knownAliases.FirstOrDefault(kvp => kvp.Value == rate.Key).Key);
}
if (File.Exists(currencyPath))
{
currencyConf = JsonConvert.DeserializeObject<ExchangePairs>(File.ReadAllText(currencyPath));
if(!knownAliases.ContainsValue(currencyConf.Base))
{
knownAliases.Add(new List<string>() { currencyConf.Base.ToLower() }, currencyConf.Base);
}
foreach (var rate in currencyConf.rates)
{
if(!knownAliases.ContainsValue(rate.Key))
{
knownAliases.Add(new List<string>() { rate.Key.ToLower() }, rate.Key);
}
AddLinearPair(currencyConf.Base, rate.Key, rate.Value);
Console.WriteLine($"{rate.Key.ToLower()} alias of {rate.Key}");
}