AppSettings.cs
798 Bytes
using Microsoft.Extensions.Configuration;
namespace HHECS.WebCommon.Config
{
public class AppSettings
{
private static IConfigurationSection appSection = null;
/// <summary>
/// 设置配置文件 Startup 注入
/// </summary>
/// <param name="section"></param>
public static void SetAppSetting(IConfigurationSection section)
{
appSection = section;
}
/// <summary>
/// 获取配置文件 AppSettings.GetAppSeting("xxx")
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetAppSeting(string key)
{
return appSection.GetSection(key)!=null ? appSection.GetSection(key).Value : "";
}
}
}