Net.core 当配置改变时触发回调函数

nuget 多安装 Microsoft.Extensions.DependencyInjection
Microsoft.Extensions.Options

https://ballardsoftware.com/adding-appsettings-json-configuration-to-a-net-core-console-application/ 怎么绑定 json config 文件 ,但不能实时更新

http://www.10tiao.com/html/391/201901/2654073587/4.html

https://stackoverflow.com/questions/38515965/cannot-set-configuration-from-json-appsettings-file-in-net-core-project

https://offering.solutions/blog/articles/2017/02/17/automatically-reload-typed-configuration-in-asp-net-core/ asp 的做法 , 但不是 c# console-application/

https://stackoverflow.com/questions/51969527/ioptionssnapshot-in-net-core-console-application-not-working 已经很接近的问题

当config值改变时, 能通知应用程序
https://stackoverflow.com/questions/53604397/how-can-i-build-an-ioptionsmonitort-for-testing

例子 : https://github.com/aspnet/Logging/issues/874

 

 

代码

 

配套配置文件 :