|
|
@ -41,9 +41,17 @@ namespace HttpClientStudy.WebApp
|
|
|
|
var configBasePath = AppContext.BaseDirectory;
|
|
|
|
var configBasePath = AppContext.BaseDirectory;
|
|
|
|
Console.WriteLine($"WebApp配置文件根目录:{configBasePath}");
|
|
|
|
Console.WriteLine($"WebApp配置文件根目录:{configBasePath}");
|
|
|
|
builder.Configuration.SetBasePath(configBasePath);
|
|
|
|
builder.Configuration.SetBasePath(configBasePath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//环境变量
|
|
|
|
|
|
|
|
builder.Configuration.AddEnvironmentVariables();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//配置文件
|
|
|
|
builder.Configuration.AddJsonFile("appsettings.json", false, true);
|
|
|
|
builder.Configuration.AddJsonFile("appsettings.json", false, true);
|
|
|
|
builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", true, true);
|
|
|
|
builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", true, true);
|
|
|
|
builder.Configuration.AddJsonFile($"configFiles/Config.json", false, true);
|
|
|
|
builder.Configuration.AddJsonFile($"configFiles/Config.json", false, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//命令行参数
|
|
|
|
|
|
|
|
builder.Configuration.AddCommandLine(args);
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 向容器注册服务
|
|
|
|
#region 向容器注册服务
|
|
|
@ -190,7 +198,6 @@ namespace HttpClientStudy.WebApp
|
|
|
|
builder.Services.AddHealthChecks();
|
|
|
|
builder.Services.AddHealthChecks();
|
|
|
|
|
|
|
|
|
|
|
|
//普通类
|
|
|
|
//普通类
|
|
|
|
|
|
|
|
|
|
|
|
builder.Services.AddScoped(provider => new Account() { Id = 0, Name = "服务注入示例", Password = "123456", Role = "IoC" });
|
|
|
|
builder.Services.AddScoped(provider => new Account() { Id = 0, Name = "服务注入示例", Password = "123456", Role = "IoC" });
|
|
|
|
builder.Services.AddScoped<AccountService>();
|
|
|
|
builder.Services.AddScoped<AccountService>();
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|