当从xml引用installer的语法如下

  1. <install type="Acme.Crm.Infrastructure.ServicesInstaller, Acme.Crm.Infrastructure"/>

Windsor允许你省略一部分命名规则。如

  1. <install type="Acme.Crm.Infrastructure.ServicesInstaller"/>

甚至可以省略命名空间。如

  1. <install type="ServicesInstaller"/>

当使用如上的简写语法时,Windsor将试图在应用程序域中的程序集(不包括BCL程序集)查找类型。如果你加载一些特殊的程序集(例如不在编辑期间进行依赖的程序集),

你可以在xml文件中配置如下节点就可以添加扫描程序集了

  1. <using assembly="Acme.Crm.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=11111111111111" />

你也可以使用.dll或.exe文件路径代替程序集名称

这个方式类似c#中的using用法,这里只是引用程序集代替了命名空间

如果没有唯一的类型被Windsor找到,则会引发异常,你将需要扩展一些信息保证类型的唯一性

Limitations

By default BCL types (defined in System.* assemblies or mscorlib) will not be matched when using shorthand syntax. Also arrays and generics containing BCL types will not be matched. You will have to use full type name then

Generics

Generic types are supported using following syntax:

For simple generic type IGeneric<ICustomer>:

  1. IGeneric`1[[ICustomer]]

For generic type with multiple generic parameters like IDoubleGeneric<ICustomer, ISpecification>:

  1. IDoubleGeneric`2[[ICustomer],[Acme.Crm.ISpecification]]

Notice you can mix and match levels of details provided, specifying some types by just name, while other by namespace and name.

For nested generic type with multiple generic parameters like IDoubleGeneric<ICustomer, IDoubleGeneric<ICustomer, IClock>>:

  1. IDoubleGeneric`2[[ICustomer],[IDoubleGeneric`2[[ICustomer],[IClock]]]]
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <configuration>
  3. <!--<using assembly="WindsorInstaller"/>-->
  4. <installers>
  5. <install type="CustomerInstaller"/>
  6. </installers>
  7. <!--<components>
  8. <component type="Service.Log,Service" service="IService.ILog,IService">
  9.  
  10. </component>
  11. </components>-->
  12. </configuration>

如上配置install,如果type的值只是类型的名称,如果该类型不在当前的程序集中,则需要using引入该类型所在的程序集才能正常解析

castle windsor学习----- Referencing types in XML 在xm文件中引用类型的更多相关文章

  1. Castle Windsor 学习-----Installer的几种安装方式

    翻译 当使用依赖注入容器时,你首先要向容器中注册你的组件,Windsor使用installers(该类型实现IWindsorInstaller接口)来封装和隔离注册的逻辑,可以使用Configurat ...

  2. [Castle Windsor]学习依赖注入

    初次尝试使用Castle Windsor实现依赖注入DI,或者叫做控制反转IOC. 参考: https://github.com/castleproject/Windsor/blob/master/d ...

  3. castle windsor学习-----XML Inline Parameters 内联参数

    当使用XML配置的时候,可能要给组件指定各种各样的依赖 1.简单的参数 参数名称不区分大小写 <component id="ping" type="Acme.Crm ...

  4. castle windsor学习-----Registering components by conventions

    注册多个组件 1.one-by-one注册组件可能是一项非常重复的工作,可以通过Classes或Types注册一组组件(你可以指定一些特定的特征) 三个步骤 注册多个类型通常采取以下结构 contai ...

  5. castle windsor学习-----Inline dependencies 依赖

    应用程序中的很多组件都会依赖其他的服务组件,很多依赖一些不合法的组件或者容器中没有的组件,例如int类型.string类型.TimeSpan类型 Windsor支持以上的场景,注册API有Depend ...

  6. castle windsor学习-----Fluent Registration API 注册

    使用xml配置和fluent注册两种搭配使用需要注意的是: 如果先在WindsorContainer构造函数指明用xml配置进行注册,如下设置 IWindsorContainer container ...

  7. castle windsor学习-------Container Events 容器的事件

    所有的事件是实现IKernelEvents 接口,已容器的Kernel属性暴露出来 1. AddedAsChildKernel 当前的容器添加子容器或其他容器时触发 2. RemovedAsChild ...

  8. castle windsor学习-----How components are created

  9. castle windsor学习----ComponentModel construction contributors

    public class RequireLoggerProperties : IContributeComponentModelConstruction { public void ProcessMo ...

随机推荐

  1. Linux中的一个命令行计算器bc简介

    假如你在一个图形桌面环境中需要一个计算器时,你可能只需要一路进行点击便可以找到一个计算器.例如,Fedora 工作站中就已经包含了一个名为 Calculator 的工具.它有着几种不同的操作模式,例如 ...

  2. Cygwin 版本的 Curl 安装,提取,使用笔记

    Cygwin 版本的 Curl 安装,提取,使用笔记 Cygwin 版本的 Curl 使其恢复 HTTPS 请求功能Cygwin 版本的 Curl 依赖的 DLL 清单提取 Cygwin 版本的 Cu ...

  3. Android开发系列之系统源码目录

    相信大家对于Google给出的那副经典Android架构图非常的熟悉,从下往上依次是Linux内核层(主要是负责硬件管理调度),HAL层(主要是硬件抽象层),libs层+Runtime,Framewo ...

  4. junit测试时报No runnable methods错误的解决方法

    1.因为你@Test时import的是@org.testng.annotations.Test所以会报错 解决方法:改为import org.junit.Test;就可以了

  5. hadoop常见算法(持续更新)

    1. 对以下数据进行排序,根据收入减去支出得到最后结余从大到小排序 账号 收入 支出 日期 zhangsan@163.com 6000 0 2014-02-20 lisi@163.com 2000 0 ...

  6. 玩转JPA(一)---异常:Repeated column in mapping for entity/should be mapped with insert=&quot;false&quot; update=&quot;fal

    近期用JPA遇到这样一个问题:Repeated column in mapping for entity: com.ketayao.security.entity.main.User column: ...

  7. oracle中nvl()函数

    oracle中nvl()函数  oracle的nvl函数的使用方法 通过查询获得某个字段的合计值,假设这个值位null将给出一个预设的默认值  select nvl(sum(t.dwxhl),1) f ...

  8. iOS - 每隔一段时间,反复执行同一个任务

    我们有时候会有这样的需求,当程序处于运行状态,每隔几秒给服务器发送一次请求. 这时我们可以这样处理: UILocalNotification *localNotification = [[UILoca ...

  9. python实现身份证识别

    github: 人脸联合语音身份认证:https://github.com/tsstss123/faceUnionVoiceRecognition 身份证识别简易版:https://github.co ...

  10. CentOS 7.x samba 服务器安装

    以下以root用户执行 1.安装: # yum install samba samba-client -y   2.设置开机启动: # systemctl enable smb.service ln ...