#nullable disable using System; using System.IO; using Newtonsoft.Json; namespace LD_SysInfo { public class AppConfig { [JsonProperty("ServerUrl")] public string ServerUrl { get; set; } = "https://yourserver.com/api/status"; [JsonProperty("EnableLogging")] public bool EnableLogging { get; set; } = true; [JsonProperty("KeepAlivePeriod")] public int KeepAlivePeriod { get; set; } = 30; [JsonProperty("SystemInfoInterval")] public int SystemInfoInterval { get; set; } = 60; [JsonProperty("ClientIdentifier")] public string ClientIdentifier { get; set; } = "your-default-client-id"; [JsonProperty("Auth")] public AuthConfig Auth { get; set; } = new(); } public class AuthConfig { [JsonProperty("Username")] public string Username { get; set; } = "testuser"; [JsonProperty("Password")] public string Password { get; set; } = "testpassword"; } public static class ConfigManager { private static readonly string ConfigPath = Path.Combine(AppContext.BaseDirectory, "config.json"); public static AppConfig LoadConfig(string? pathOverride = null) { string path = pathOverride ?? ConfigPath; if (!File.Exists(path)) throw new FileNotFoundException($"Config file not found at {path}"); string json = File.ReadAllText(path); return JsonConvert.DeserializeObject(json) ?? new AppConfig(); } } }