合并.net配置文件

时间:2013-03-21 16:56:36

标签: c# .net app-config

我的应用程序目前有2个配置文件。

  1. 的App.config
  2. Custom.config
  3. App.config通过自定义部分处理程序引用Custom.config,如下所示:

    <configuration> <configSections>
    <section name="Custom" type="MyApp.CustomConfigSection, MyApp" /> </configSections> <Custom configSource="Custom.config" /> </configuration>

    问题是Custom.config文件包含一个包含许多元素的部分。我想把它分开,所以有些元素在一个文件中,有些在另一个文件中。

    e.g。现在我有

    '<Custom>
         <Group1 ../>
         <Group2 ../>
         <Group3 ../>
    </Custom>
    

    我想制作两个或更多文件,如下所示。

    '<Custom>
        <Group1 ../>
     </Custom>'
    
    '<Custom>
         <Group2 ../>
         <Group3 ../>
     </Custom>'
    

    目前我将ConfigurationManager.GetSection(“Custom”)称为MyCustomConfigSection。然后,我有许多具有各种配置属性的类,这些属性由.net配置自动填充。

    有没有办法进行拆分,或者你不能将1个部分拆分成多个文件?

    提前致谢

0 个答案:

没有答案