Reduce redundant logs when setting flags

This commit is contained in:
pizzaboxer 2023-07-24 12:22:02 +01:00
parent d1861262fc
commit 6547118383
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8

View File

@ -110,13 +110,19 @@ namespace Bloxstrap
{
if (value is null)
{
Prop.Remove(key);
if (Prop.ContainsKey(key))
App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending");
Prop.Remove(key);
}
else
{
Prop[key] = value.ToString()!;
if (Prop.ContainsKey(key))
App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' from '{Prop[key]}' to '{value}' is pending");
else
App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' to '{value}' is pending");
Prop[key] = value.ToString()!;
}
}
@ -157,13 +163,13 @@ namespace Bloxstrap
public string GetPresetEnum(IReadOnlyDictionary<string, string> mapping, string prefix, string value)
{
foreach (var mode in mapping)
foreach (var pair in mapping)
{
if (mode.Key == mapping.First().Key)
if (pair.Value == "None")
continue;
if (App.FastFlags.GetPreset($"{prefix}.{mode.Value}") == value)
return mode.Key;
if (GetPreset($"{prefix}.{pair.Value}") == value)
return pair.Key;
}
return mapping.First().Key;