namespace Utility
{
public class ConfigurationHelper
{
//先 NuGet:Microsoft.Extensions.Configuration
//ConfigurationHelper.Configure(builder.Configuration);//在入口注册(写在var app = builder.Build();)之前
//获取值方法
//var Serve = ConfigurationHelper.GetConfigValueByKey("AppSettings:Serve");
//var AllowedHosts = ConfigurationHelper.GetConfigValueByKey("AllowedHosts");
public static void Configure(IConfiguration config)
{
_configuration = config;
}
public static IConfiguration _configuration;
public static string GetConfigValueByKey(string key)
{
return _configuration[key];
}
}
}