<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Unity.Configuration"/>
</configSections>
<unity>
<containers>
<container name="lesson">
<register type="MyInterface.IRun,MyInterface" mapTo="trunk.Trunk, trunk"/>
</container>
</containers>
</unity>
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "DI.Config");//找配置文件的路径
// ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
//fileMap.ExeConfigFilename = "DI.Config";//找配置文件的路径
Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
UnityConfigurationSection section = (UnityConfigurationSection)configuration.GetSection(UnityConfigurationSection.SectionName);
IUnityContainer container = new UnityContainer();
section.Configure(container, "lesson");
IRun run = container.Resolve<IRun>();
OneDay day = new OneDay(run);
</configuration>