using ColdMint.scripts.debug; using ColdMint.scripts.openObserve; using ColdMint.scripts.serialization; using Godot; namespace ColdMint.scripts; public class AppConfig { /// /// Load configuration from file /// 从文件加载配置 /// public static AppConfigData? LoadFromFile() { var appConfigExists = FileAccess.FileExists(Config.AppConfigPath); if (!appConfigExists) { LogCat.LogWarning("appConfig_not_exist"); return null; } var appConfigFileAccess = FileAccess.Open(Config.AppConfigPath, FileAccess.ModeFlags.Read); var yamlData = appConfigFileAccess.GetAsText(); appConfigFileAccess.Close(); return YamlSerialization.Deserialize(yamlData); } /// /// ApplyAppConfig /// 应用配置 /// /// public static void ApplyAppConfig(AppConfigData appConfigData) { if (appConfigData.OpenObserve != null) { LogCollector.UpdateHttpClient(appConfigData.OpenObserve); } } } public class AppConfigData { /// /// OpenObserve configuration information /// OpenObserve的配置信息 /// // ReSharper disable UnusedAutoPropertyAccessor.Global public OpenObserve? OpenObserve { get; set; } // ReSharper restore UnusedAutoPropertyAccessor.Global } /// /// OpenObserve Configuration information /// OpenObserve配置信息 /// public class OpenObserve { /// /// server address /// 服务器地址 /// // ReSharper disable UnusedAutoPropertyAccessor.Global public string? Address { get; set; } // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Access Token /// 访问密匙 /// // ReSharper disable UnusedAutoPropertyAccessor.Global public string? AccessToken { get; set; } // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Organization ID /// 组织ID /// // ReSharper disable UnusedAutoPropertyAccessor.Global public string? OrgId { get; set; } // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Stream Name /// 流名称 /// // ReSharper disable UnusedAutoPropertyAccessor.Global public string? StreamName { get; set; } // ReSharper restore UnusedAutoPropertyAccessor.Global }