windsor = new WindsorContainer( new XmlInterpreter(new ConfigResource));
在配置文件的<configSections>配置节里首先加入下面的配置,关于这点的作用在此就不多解释,详细可以看看我之前写的文章:
<configSections>
<!-- Specify the castle section handler -->
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/>
上面我门定义了castle配置节点,那castle的配置节点该怎么去配置呢,看看下面的配置代码:
<castle>
<include uri="file://castle-dao.config"/>
</castle>
在castle-dao.config文件中
<configuration>
<components>
<component id="dao" service="dao" type="daoimpl">
</components>
</configuration>
本文介绍了如何使用 Castle Windsor 进行依赖注入配置。通过在配置文件中定义 castle 节点并引用外部配置文件来实现组件和服务的绑定。
2597

被折叠的 条评论
为什么被折叠?



