I'm creating a little console application that creates a Lucene index from an Sql Database. This application will be run with a single parameter. This parameter will define what connection string it will use and where the destination file should be placed.
I would like to store the connection strings and the target paths in the app.config file. Is it possible to group settings somehow? For example I would like that if the parameter "ABC" is given, connectionstring1 is used and targetPathBanana is used.
This following example doesn't work but I think illustrates my intention
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<abc>
<appSettings>
<add key="targetBasePath" value="\\Thor\lucene\abc"/>
</appSettings>
<connectionStrings>
<add name="commonString"
connectionString="Data Source=thor;Persist Security Info=True;User ID=****;Password=****"/>
</connectionStrings>
</abc>
<123>
<appSettings>
<add key="targetBasePath" value="\\Loki\temp\lucene"/>
</appSettings>
<connectionStrings>
<add name="commonString"
connectionString="Data Source=helga;Persist Security Info=True;User ID=****;Password=****"/>
</connectionStrings>
</123>
</configuration>
I know I could just make the names of the keys follow a naming convention, but I'm curious if this could be solved in a way that's less convention-based.