Sort JSON config on save, null check

This commit is contained in:
N00MKRAD
2021-05-17 17:54:08 +02:00
parent ad3daccff1
commit d993d7c13a

View File

@@ -40,7 +40,8 @@ namespace Flowframes.IO
private static void WriteConfig()
{
File.WriteAllText(configPath, JsonConvert.SerializeObject(cachedValues, Formatting.Indented));
SortedDictionary<string, string> cachedValuesSorted = new SortedDictionary<string, string>(cachedValues);
File.WriteAllText(configPath, JsonConvert.SerializeObject(cachedValuesSorted, Formatting.Indented));
}
private static void Reload()
@@ -50,6 +51,9 @@ namespace Flowframes.IO
Dictionary<string, string> newDict = new Dictionary<string, string>();
Dictionary<string, string> deserializedConfig = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(configPath));
if (deserializedConfig == null)
deserializedConfig = new Dictionary<string, string>();
foreach (KeyValuePair<string, string> entry in deserializedConfig)
newDict.Add(entry.Key, entry.Value);