Core 获取配置文件
public class UploadService
{
//实例化配置节点
private readonly IConfiguration configuration;
public UploadService(IConfiguration configuration)
{
this.configuration = configuration;
}}
//获取配置文件值
var connStr = configuration.GetSection("ConnectionStrings")["AA"];
}
appseting.json:
{
"Counts": {
"IGBT": 7,
"IGCT": 5
},
"ConnectionStrings": {
"PP": "TTTTT",
"AA": "TTTTT",
"BB": "TTTTT",
"FactoryCodes": "111,222,333,444,555,666,777",
"TraceTest": "TTTTT",
"TTke": "sTTTTT"
}
}
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();
var workflowFilterAll = configuration["AuthCheck"];
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();
var workflowFilterAll = configuration["workflowFilterAll"];
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"AuthCheck": "False",
"ConnectionStrings": {
"SQLServerConnString": "SATAWTEWA",
"RedisConnectionString": "TTTTTTT"
},
"KPIItemConfig": {
"Step1BaseTime": 240,
"Step2BaseTime": 240,
"Step3BaseTime": 120,
"Step4BaseTime": 30,
"Step1Weight": 25,
"Step2Weight": 25,
"Step3Weight": 25,
"Step4Weight": 25,
"BaseScore": 80,
"ExtendTime": 10,
"ExtendScore": 8
},
"KPIYearsConfig": {
"ResponseRateWeight": 25,
"AbnormalTimesWeight": 25,
"GreatAbnormalTimesWeight": 25,
"CloseRateWeight": 25,
"AbnormalBaseCount": 50,
"AbnormalScoreReduction": 5,
"GreatAbnormalBaseCount": 0,
"GreatAbnormalScoreReduction": 50
},
"workflowFilterAll": "AAA",
"workflowFilter": "BBB",
"workflowId": "CCC",
"OAAutoLogin": "DDD",
"HostIpAddr": "CCC",
"mainTableName": "formtable_",
"appId": "1EEE",
"BelongCampus": "ZT"
}
标签:Core,读取,25,配置,workflowFilterAll,var,configuration,TTTTT From: https://www.cnblogs.com/zhan-shuai/p/17980444