I have the following in my app.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
</appSettings>
<services>
<service Site="AAA1.1" Release="QA" Connection="..." Monitor="True"/>
<service Site="AAB1.2" Release="QA" Connection="..." Monitor="True"/>
<service Site="AAC1.2" Release="QA" Connection="..." Monitor="True"/>
<service Site="AAD3.1" Release="QA" Connection="..." Monitor="True"/>
<service Site="AAE3.2" Release="QA" Connection="..." Monitor="True"/>
<service Site="AAF5.1" Release="QA" Connection="..." Monitor="True"/>
<service Site="AAG5.2" Release="QA" Connection="..." Monitor="True"/>
</services>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
I know I can retrieve the ‘services’ section as follows:
var section = configuration.GetSection("services");
What I don’t know how to do is to get the child collection of seven ‘service’ elements once I have the section.
It is arguable best practice to create your own Custom Configuration Section this allows you to strongly type your collection, set default values for parameters and handle things like duplicate entries etc.