views:

19

answers:

0

Is it possible and how to instantiate a custom System.Configuration.ConfigurationSection derived class from a different source (not dependent on App.config)?

Here is what i want to get:

[TestMethod]
public void WorkWithALoadedConfiguration()
{
 ProjectConfiguration projectConfiguration = 
  LoadProjectConfiguration(filenameOrStreamOrXElementOrXmlSourceString);
 // ...
}

Here is what i've got:

public class MyConfigurationSection: ConfigurationSection
{
 // ...
}

configuration\aConfigInstance.config contents:

<?xml version="1.0"?>
<aConfigInstance>
 ...
</aConfigInstance>

Here is how it's used in the runtime:

Web.config contents:

<section
 name="aConfigInstance"
 type="MyProject.Configuration.MyConfigurationSection"
 allowLocation="true" allowDefinition="Everywhere" />
<!-- ... -->
<aConfigInstance configSource="configuration\aConfigInstance.config" />