Creating a System.Configuration.Configuration configuration by merging two configuration files?

I have two .config files and I need System.Configuration.Configuration , which is a partial merge between them?

I can read files as XML and easily create the desired merge, but then it's a string or XDocument. However, the .net System.Configuration is apparently a string file, so I would have to write it to the temp directory, which I would like to avoid.

Is there any way to do this?

An example config1.config:

<configuration>
    <appSettings>
        <add key="CacheTime" value="300" />
    </appSettings>
    <system.serviceModel>
        <behaviors>
          <endpointBehaviors>
            <behavior name="MyBehavior">
               <!-- snipped -->
            </behavior>
          </endpointBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

and config2.config:

<configuration>
    <system.serviceModel>
     <client>
          <endpoint name="MyEndpoint" address="net.tcp://...."
            behaviorConfiguration="MyBehavior" binding="netTcpBinding"
            contract="IMyContract">
          </endpoint>
     </client>
    </system.serviceModel>
</configuration>

, AppSetting, . WCF, WCF, System.Configuration.Configuration.

config1 config2 - - , config1 config4 config 3 config4 config2 config3.

+5

All Articles