private static string GetCustomSettings(string key) { var config = new ConfigurationBuilder() .AddInMemoryCollection() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .Build(); return config.GetSection("CustomSettings").GetValue(key, string.Empty); } // 获取自定义value public static string WXWarningClosedTemplateID => GetCustomSettings("xxx");