Here's the idea I had:
I want a small executable to have an app.config file with multiple sections that are situated under the sectionGroup "applicationSettings" (not "appSettings", I don't need to write to the file). Each section would have a name corresponding to a module that should be loaded if set.
Here's an example:
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Executable" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="FirstModule" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<Executable>
<setting name="MyFirstSetting" serializeAs="String">
<value>My awesome feature setting</value>
</setting>
</Executable>
<FirstModule path="path to the modules assembly">
<setting name="ImportantSettingToTheModule" serializeAs="String">
<value>Some important string</value>
</setting>
</FirstModule>
</applicationSettings>
</configuration>
Now if I define the FirstModule section, I want my application to load its assembly. If the section is not defined, the module should not be loaded. This should be true for not only one module but a not yet defined number of them.
So I basically need to find out about the defined sections at runtime. How would I do that?
In addition I want this to become a portable executable (= it has to run on Mono as well) that is backwards compatible to .NET 2.0.
It might be interesting to have a look at the project on GitHub (currently at this commit).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…