当从xml引用installer的语法如下

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

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

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

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

<install type="ServicesInstaller"/>

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

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

<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>:

IGeneric`1[[ICustomer]]

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

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>>:

IDoubleGeneric`2[[ICustomer],[IDoubleGeneric`2[[ICustomer],[IClock]]]]
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!--<using assembly="WindsorInstaller"/>-->
<installers>
<install type="CustomerInstaller"/>
</installers>
<!--<components>
<component type="Service.Log,Service" service="IService.ILog,IService"> </component>
</components>-->
</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. Android加入新的视频格式--媒体库扫描

    需求:在mediaprovider数据库中加入.mov后缀格式的视频文件 能够使用工具MediaInfo_GUI_0.7.67_Windows.3243836749.exe 查看mov文件编码格式类型 ...

  2. jar包解压与打包

    首先感谢大神的指导:https://blog.csdn.net/mr_pang/article/details/47028921 1.首先准备一个能运行的jar文件,我们使用第三方解压工具进行解压wi ...

  3. LayoutInflater这个类还是非常有用的,它的作用类似于findViewById()。 但他是找XML文件并实例化

    在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById().不同点是LayoutInflater是用来找res/layout/下的xml布局文件,并且实例 ...

  4. struts2中在Action中如何获取servlet的api?

    1.通过ActionContext类(拿到的不是真正的servlet api,而是一个map) ActionContext context = ActionContext.getContext(); ...

  5. Ubuntu 16.04 关闭/打开笔记本触摸板

    由于笔记本触摸板太多灵敏,影响使用,所以禁用掉触摸板. 禁用触摸板命令: sudo rmmod psmouse 启用触摸板命令 sudo modprobe psmouse 注意:启用之后可能会有几秒钟 ...

  6. 如何搭建maven项目和搭建ssm框架

    1.基本概念 1.1.Spring Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnson 在其著作Expert One-On-One ...

  7. Shiro 认证失败返回JSON

    Shiro框架默认认证失败后会返回到登录页面,在前后端分离项目中,需要返回JSON数据,以便前端或者app端解析处理. 实现方式: 1. 扩展shiro框架的UserFilter类,重写redirec ...

  8. 关于iphone自动播放音频和视频问题的解决办法

    大家都知道 做移动端 会遇到音频和视频无法自动播放问题(我也遇到了)于是想办法解决这个问题 我只是找到了在微信中解决的办法(如果谁有在别的浏览器有这个办法  请私聊我 )我是没有发现 document ...

  9. xcode ERROR ITMS

    1.ERROR ITMS-90046 /90085: "Invalid Code Signing Entitlements. Your application bundle's signat ...

  10. centos7.0 增加/usr分区的容量减少home分区的大小

    把/home内容备份,然后将/home文件系统所在的逻辑卷删除,扩大/root文件系统,新建/home:tar cvf /tmp/home.tar /home #备份/homeumount /home ...