How to load appsetting.json section into Dictionary in .NET Core?

后端 未结 10 1509
误落风尘
误落风尘 2020-12-05 16:49

I am familiar w/ loading an appsettings.json section into a strongly typed object in .NET Core startup.cs. For example:

public class CustomSection 
{
   publ         


        
10条回答
  •  没有蜡笔的小新
    2020-12-05 17:30

    By far the simplest method would be to define your configuration class to inherit from the Dictionary type you want to support.

    public class MobileConfigInfo:Dictionary{
    }
    

    Then your startup and dependency injection support would be exactly the same as for any other configuration type.

提交回复
热议问题