using EC.Helper.FileExt; using Microsoft.Extensions.Configuration; using System.IO; namespace OnvifSocketServer { public class AppConfig { #region Attr private static IConfiguration config; private static IConfiguration Config { get { if (config == null) { string configPath = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"); config = JsonHelper.ReadConfiguration(configPath); } return config; } } public static T Get(string key) { return Config.GetValue(key); } #endregion Attr #region Apis public static string GetApi(string key) { return Get($"Apis:{key}"); } public static string GetOnvifHttpUrl() { return GetApi("onvif_http_url"); } public static string GetOnvifHttpsUrl() { return GetApi("onvif_https_url"); } #endregion Apis } }