拆分统一配置文件 [英] split unity configuration file

查看:81
本文介绍了拆分统一配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将单位配置拆分为n个不同的文件,以便我可以将其中一些文件选择到同一单位容器中?

I need to split my unity configuration into n different files so i can select it some of those files into the same unity container??

推荐答案

确定。为时已晚,但我可以回答。
您需要这样的东西:

OK. It's too late but I could answer. You need something like this:

    private IUnityContainer ReadContainer()
    {
        var unityCommon = (UnityConfigurationSection)ConfigurationManager.GetSection("unityCommon");
        IUnityContainer returnValue = new UnityContainer();
        unityCommon.Configure(returnValue, "Common"); // Unnamed <container> element
        var unitySpecific = (UnityConfigurationSection)ConfigurationManager.GetSection("unitySpecific");
        unitySpecific.Configure(returnValue, "Specific"); // 
        return returnValue;
    }

并将其放在app.config中:

And have this in app.config:

  <configSections>
        <section name="unityCommon" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
        <section name="unitySpecific" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
  </configSections>

  <unityCommon configSource="unity.common.config.xml" />

这篇关于拆分统一配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆