当前位置:网站首页>C# netcore中 配置帮助类IConfiguration
C# netcore中 配置帮助类IConfiguration
2022-06-27 05:32:00 【望天hous】
using System;
using System.IO;
namespace Microsoft.Extensions.Configuration;
public static class ConfigurationHelper
{
public static IConfigurationRoot BuildConfiguration(
AbpConfigurationBuilderOptions options = null,
Action<IConfigurationBuilder> builderAction = null)
{
options = options ?? new AbpConfigurationBuilderOptions();
if (options.BasePath.IsNullOrEmpty())
{
options.BasePath = Directory.GetCurrentDirectory();
}
var builder = new ConfigurationBuilder()
.SetBasePath(options.BasePath)
.AddJsonFile(options.FileName + ".json", optional: true, reloadOnChange: true);
if (!options.EnvironmentName.IsNullOrEmpty())
{
builder = builder.AddJsonFile($"{
options.FileName}.{
options.EnvironmentName}.json", optional: true, reloadOnChange: true);
}
if (options.EnvironmentName == "Development")
{
if (options.UserSecretsId != null)
{
builder.AddUserSecrets(options.UserSecretsId);
}
else if (options.UserSecretsAssembly != null)
{
builder.AddUserSecrets(options.UserSecretsAssembly, true);
}
}
builder = builder.AddEnvironmentVariables(options.EnvironmentVariablesPrefix);
if (options.CommandLineArgs != null)
{
builder = builder.AddCommandLine(options.CommandLineArgs);
}
builderAction?.Invoke(builder);
return builder.Build();
}
}
边栏推荐
- DAST black box vulnerability scanner part 6: operation (final)
- 【NIPS 2017】PointNet++:度量空间中点集的深层次特征学习
- Obtenir le volume du système à travers les plateformes de l'unit é
- 011 C language basics: C scope rules
- 面试:Selenium 中有哪几种定位方式?你最常用的是哪一种?
- Luogu p2939 [usaco09feb]revamping trails G
- Some articles about component packaging and my experience
- Microservice system design -- API gateway service design
- AD22 gerber files 点开 gerber steup 界面 有问题 官方解决方法
- 微信小程序WebSocket使用案例
猜你喜欢

Dual position relay dls-34a dc0.5a 220VDC

Microservice system design -- Distributed timing service design
![[622. design cycle queue]](/img/f2/d499ac9ddc50b73f8c83e8b6af2483.png)
[622. design cycle queue]
![Navigation [machine learning]](/img/79/8311a409113331e72f650a83351b46.png)
Navigation [machine learning]

双位置继电器HJWS-9440

Avoid asteroids

Pycharm 中 Terminal 无法进入 venv 环境的问题

双位置继电器RXMD2-1MRK001984 DC220V

双位置继电器RXMVB2 R251 204 110DC
![[station B up dr_can learning notes] Kalman filter 3](/img/40/d3ec97be2f29b76a6c049c26ff4998.gif)
[station B up dr_can learning notes] Kalman filter 3
随机推荐
【622. 设计循环队列】
AcWing 第 57 场周赛---BC题挺好
C language implementation timer
Leetcode298 weekly race record
LeetCode-515. 在每个树行中找最大值
pycharm 如何安装 package
Luogu p2939 [usaco09feb]revamping trails G
[FPGA] design and implementation of frequency division and doubling based on FPGA
Machunmei, the first edition of principles and applications of database... Compiled final review notes
DAST black box vulnerability scanner part 6: operation (final)
洛谷P4683 [IOI2008] Type Printer 题解
双位置继电器DLS-34A DC0.5A 220VDC
[622. design cycle queue]
unity点光源消失
neo4j图数据库基本概念
Chapter 2 Introduction to key technologies
Ad22 Gerber files Click to open the Gerber step interface. Official solutions to problems
Opencv implements object tracking
Microservice system design - service fusing and degradation design
Vue学习笔记(五)Vue2页面跳转问题 | vue-router路由概念、分类与使用 | 编程式路由导航 | 路由组件的缓存 | 5种路由导航守卫 | 嵌套路由 | Vue2项目的打包与部署