deepakaitr Ответов: 0

Загрузите applicationsettings.json, раздел специфические настройки с помощью ioption


HI All

We are converting our project module in .net core and a new problem come up, please help me to get the solution for this.

1) We have configuration file with section like below

<RealtimeConfig environment="Auto">
<inheritData environment="Auto" base="Test"/>

<RealtimeConnectionStrings>
<Dev>
	<DevAccount1 Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername; Password=myPassword; />
	<DevAccount2 Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername; Password=myPassword; />
</Dev>
<Test>
	<TestAccount1 Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername; Password=myPassword; />
	<TestAccount2 Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername; Password=myPassword; />
</Test>
<RealtimeConnectionStrings/>

<RealtimeConnectionURLs>
<Dev>
	<DevAccount1="http://www.example.com/" />
	<DevAccount2="http://www.example.com/" />
</Dev>
<Test>
	<TestAccount2="http://www.example.com/" />
	<TestAccount1="http://www.example.com/" />
</Test>
<RealtimeConnectionURLs />
<RealtimeConfig>

2) Based on InheritData tag it is finding the environment and base.
3) Depends on base attribute value e.g. if the value is "Test" it will take connectionstrings and connectionURIs from Test section 
4) So can we convert this logic in IOption<Class> which is provided by .Net Core.

We can't keep multiple appSetting.Json file(Environment specific), because other services uses same config file or will use same appSettings.Json file.

Please help me to solve this issue asap.

Thanks 


Что я уже пробовал:

configuration reader 
IOption

0 Ответов