mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-14 07:48:58 +00:00
Improved the readability of the settings.json file by using indentation and enum names instead of numbers; fixes #53
This commit is contained in:
2 files changed
+12
-2
No files matched your search
@@ -1,4 +1,6 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
using AIStudio.Provider;
|
using AIStudio.Provider;
|
||||||
using AIStudio.Settings.DataModel;
|
using AIStudio.Settings.DataModel;
|
||||||
|
|
||||||
@@ -13,6 +15,12 @@ public sealed class SettingsManager
|
|||||||
{
|
{
|
||||||
private const string SETTINGS_FILENAME = "settings.json";
|
private const string SETTINGS_FILENAME = "settings.json";
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions JSON_OPTIONS = new()
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Converters = { new JsonStringEnumConverter() },
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The directory where the configuration files are stored.
|
/// The directory where the configuration files are stored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -101,7 +109,7 @@ public sealed class SettingsManager
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var settingsJson = await File.ReadAllTextAsync(settingsPath);
|
var settingsJson = await File.ReadAllTextAsync(settingsPath);
|
||||||
var loadedConfiguration = JsonSerializer.Deserialize<Data>(settingsJson);
|
var loadedConfiguration = JsonSerializer.Deserialize<Data>(settingsJson, JSON_OPTIONS);
|
||||||
if(loadedConfiguration is null)
|
if(loadedConfiguration is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -120,7 +128,7 @@ public sealed class SettingsManager
|
|||||||
if(!Directory.Exists(ConfigDirectory))
|
if(!Directory.Exists(ConfigDirectory))
|
||||||
Directory.CreateDirectory(ConfigDirectory!);
|
Directory.CreateDirectory(ConfigDirectory!);
|
||||||
|
|
||||||
var settingsJson = JsonSerializer.Serialize(this.ConfigurationData);
|
var settingsJson = JsonSerializer.Serialize(this.ConfigurationData, JSON_OPTIONS);
|
||||||
await File.WriteAllTextAsync(settingsPath, settingsJson);
|
await File.WriteAllTextAsync(settingsPath, settingsJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# v0.8.6, build 168
|
||||||
|
- Improved the readability of the `settings.json` file by using indentation and enum names instead of numbers
|
||||||
Reference in new issue
Block a user