官术网_书友最值得收藏!

Summary

Because JSON is the standard nowadays, we should stick with the JSON provider and enable the reloading of the configuration upon changes. We should add the common file first, and then optional overrides for each of the different environments (beware the order in which you add each source). We learned how the default configuration of ASP.NET Core already loads JSON files, including different ones for the different environments.

We then saw how to use configuration sections to better organize the settings, and we also looked at using POCO wrappers for them.

So, this made us ponder whether we should use IOptions<T> or our own POCO classes to inject configuration values. Well, if you don't want to pollute your classes or assemblies with references to .NET Core configuration packages, you should stick to your POCO classes. We're not too worried about this, so we recommend keeping the interface wrappers.

We will use IOptionsSnapshot<T> instead of IOptions<T> so that we always get the latest version of the configuration settings.

After this, we looked at feature toggling, to quickly enable or disable features that are just on or off.

In this chapter, we saw the many ways in which we can provide configuration to an ASP.NET Core application. We learned how to build a simple provider that takes configuration from the Windows Registry. We then discussed the many ways in which we can inject configuration settings using the built-in dependency injection framework, and how to be notified of changes in the configuration sources.

主站蜘蛛池模板: 延寿县| 新巴尔虎右旗| 呼和浩特市| 柳江县| 凤山县| 安义县| 鸡泽县| 平邑县| 德格县| 游戏| 潢川县| 天等县| 化隆| 贵溪市| 四会市| 民和| 稷山县| 郁南县| 文安县| 尚义县| 东港市| 固安县| 辰溪县| 桂林市| 武川县| 赤城县| 阿图什市| 孙吴县| 饶阳县| 永善县| 民勤县| 慈溪市| 额尔古纳市| 库伦旗| 兴山县| 汝城县| 策勒县| 渝中区| 藁城市| 高邮市| 南涧|