Skip to content

Commit

Permalink
Save all FastFlag values as strings
Browse files Browse the repository at this point in the history
turns out that the json deserializer does not, in fact, automatically typecast to string
  • Loading branch information
pizzaboxer committed Jul 23, 2023
1 parent df422cc commit 62a44f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions Bloxstrap/FastFlagManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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");

Expand Down Expand Up @@ -124,8 +124,8 @@ public void SetValue(string key, object? value)
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;
}
Expand Down Expand Up @@ -169,6 +169,16 @@ public string GetPresetEnum(IReadOnlyDictionary<string, string> mapping, string
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void ReloadList()
{
// Enabled = true,
Name = pair.Key,
Value = pair.Value
Value = pair.Value.ToString()!
};

/* if (entry.Name.StartsWith("Disable"))
Expand Down

0 comments on commit 62a44f1

Please sign in to comment.