Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 


What I have tried:

configuration reader 
IOption
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900