From 226c0105ba39258f894c53cbc56bc4060bae143e Mon Sep 17 00:00:00 2001 From: Chernykh Aleksandr Date: Thu, 23 Apr 2026 01:22:54 +0300 Subject: [PATCH] commit --- src/KeyKeeper/Views/AppSettings.cs | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/KeyKeeper/Views/AppSettings.cs diff --git a/src/KeyKeeper/Views/AppSettings.cs b/src/KeyKeeper/Views/AppSettings.cs new file mode 100644 index 0000000..e658f18 --- /dev/null +++ b/src/KeyKeeper/Views/AppSettings.cs @@ -0,0 +1,42 @@ +using System.IO; +using System.Text.Json; + +namespace KeyKeeper; + +public static class AppSettings +{ + private static readonly string FilePath = "settings.json"; + + public static bool ExitOnRepositoryClose { get; set; } = false; + + // Сохранение в файл + public static void Save() + { + var data = new { ExitOnRepositoryClose }; + string json = JsonSerializer.Serialize(data); + File.WriteAllText(FilePath, json); + } + + // Загрузка из файла + public static void Load() + { + if (File.Exists(FilePath)) + { + try + { + string json = File.ReadAllText(FilePath); + var data = JsonSerializer.Deserialize(json); + if (data != null) + { + ExitOnRepositoryClose = data.ExitOnRepositoryClose; + } + } + catch { /* Если файл поврежден, просто используем значения по умолчанию */ } + } + } + + private class SettingsData + { + public bool ExitOnRepositoryClose { get; set; } + } +} \ No newline at end of file