开发者

split unity configuration file

I need to split my unity configuration into n different files so i ca开发者_如何学Pythonn 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;
    }

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" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜