Save all FastFlag values as strings

turns out that the json deserializer does not, in fact, automatically typecast to string
This commit is contained in:
pizzaboxer 2023-07-23 23:45:40 +01:00
parent df422cceb5
commit 62a44f1c2c
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 14 additions and 4 deletions

View File

@ -3,7 +3,7 @@ using System.Windows.Media.Animation;
namespace Bloxstrap
{
public class FastFlagManager : JsonManager<Dictionary<string, string>>
public class FastFlagManager : JsonManager<Dictionary<string, object>>
{
public override string FileLocation => Path.Combine(Directories.Modifications, "ClientSettings\\ClientAppSettings.json");
@ -124,8 +124,8 @@ namespace Bloxstrap
public string? GetValue(string key)
{
// check if we have an updated change for it pushed first
if (Prop.TryGetValue(key, out string? value) && value is not null)
return value;
if (Prop.TryGetValue(key, out object? value) && value is not null)
return value.ToString();
return null;
}
@ -169,6 +169,16 @@ namespace Bloxstrap
return mapping.First().Key;
}
public override void Save()
{
// convert all flag values to strings before saving
foreach (var pair in Prop)
Prop[pair.Key] = pair.Value.ToString()!;
base.Save();
}
public override void Load()
{
base.Load();

View File

@ -42,7 +42,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
{
// Enabled = true,
Name = pair.Key,
Value = pair.Value
Value = pair.Value.ToString()!
};
/* if (entry.Name.StartsWith("Disable"))