You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

49 lines
1.3 KiB

using Microsoft.Extensions.Configuration;
using Znyc.Cloudcar.Admin.Commons.Core.App;
namespace Znyc.Cloudcar.Admin.Commons
{
/// <summary>
/// 配置文件读取操作
/// </summary>
public class Configs
{
public static IConfiguration configuration;
static Configs()
{
configuration = App.GetService<IConfiguration>();
}
/// <summary>
/// 根据Key获取数配置内容
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static IConfigurationSection GetSection(string key)
{
return configuration.GetSection(key);
}
/// <summary>
/// 根据section和key获取配置内容
/// </summary>
/// <param name="section"></param>
/// <param name="key"></param>
/// <returns></returns>
public static string GetConfigurationValue(string section, string key)
{
return GetSection(section)?[key];
}
/// <summary>
/// 根据Key获取数据库连接字符串
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetConnectionString(string key)
{
return configuration.GetConnectionString(key);
}
}
}