1: public static IUnityContainer GetContainerFromAnotherFile(string unityConfigName,string containerName)
2: {
3: UnityConfigurationSection section = GetUnityConfigSection();
4: UnityContainerElement configElement = new UnityContainerElement();
5: IUnityContainer container = new UnityContainer();
6:
7: var map = new ExeConfigurationFileMap();
8: map.ExeConfigFilename = unityConfigName;
9:
10: var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
11: section = (UnityConfigurationSection)config.GetSection("unity");
12: container = new UnityContainer();
13: section.Containers[containerName].Configure(container);
14: configElement.Configure(container);
15:
16: return container;
17:
18: }
posted @ mercoledì 7 ottobre 2009 02:21