castle windsor学习----- Referencing types in XML 在xm文件中引用类型
当从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文件中引用类型的更多相关文章
- Castle Windsor 学习-----Installer的几种安装方式
翻译 当使用依赖注入容器时,你首先要向容器中注册你的组件,Windsor使用installers(该类型实现IWindsorInstaller接口)来封装和隔离注册的逻辑,可以使用Configurat ...
- [Castle Windsor]学习依赖注入
初次尝试使用Castle Windsor实现依赖注入DI,或者叫做控制反转IOC. 参考: https://github.com/castleproject/Windsor/blob/master/d ...
- castle windsor学习-----XML Inline Parameters 内联参数
当使用XML配置的时候,可能要给组件指定各种各样的依赖 1.简单的参数 参数名称不区分大小写 <component id="ping" type="Acme.Crm ...
- castle windsor学习-----Registering components by conventions
注册多个组件 1.one-by-one注册组件可能是一项非常重复的工作,可以通过Classes或Types注册一组组件(你可以指定一些特定的特征) 三个步骤 注册多个类型通常采取以下结构 contai ...
- castle windsor学习-----Inline dependencies 依赖
应用程序中的很多组件都会依赖其他的服务组件,很多依赖一些不合法的组件或者容器中没有的组件,例如int类型.string类型.TimeSpan类型 Windsor支持以上的场景,注册API有Depend ...
- castle windsor学习-----Fluent Registration API 注册
使用xml配置和fluent注册两种搭配使用需要注意的是: 如果先在WindsorContainer构造函数指明用xml配置进行注册,如下设置 IWindsorContainer container ...
- castle windsor学习-------Container Events 容器的事件
所有的事件是实现IKernelEvents 接口,已容器的Kernel属性暴露出来 1. AddedAsChildKernel 当前的容器添加子容器或其他容器时触发 2. RemovedAsChild ...
- castle windsor学习-----How components are created
- castle windsor学习----ComponentModel construction contributors
public class RequireLoggerProperties : IContributeComponentModelConstruction { public void ProcessMo ...
随机推荐
- maven设置本地仓库地址和设置国内镜像
<?xml version="1.0" encoding="UTF-8"?> <!-- 英文注释已经被删除了,直接修改本地仓库地址用就行了. ...
- inotify+rsync
backup_to_rsync.sh #!/bin/bash #source function library . /etc/init.d/functions rsync_host=rsync.eti ...
- FPGA开发流程
需求说明:Verilog设计 内容 :FPGA开发基本流程及注意事项 来自 :时间的诗 原文来自:http://www.dzsc.com/data/2015-3-16/1080 ...
- java -cp 命令 java jar 命令和 hadoop jar 命令
-cp 和 -classpath 一样,是指定类运行所依赖其他类的路径,通常是类库,jar包之类,需要全路径到jar包,window上分号“;” java -cp .;myClass.jar pa ...
- member access within misaligned address 0x000000000031 for type 'struct ListNode', which requires 8 byte alignment
在做LeetCode的two sum题目的时候,提交代码遇到了如题的runtime error,后来在一篇博客上看到了解决方法. 现有如下结构体: struct ListNode { int val; ...
- PHP浮点数运算精度造成的,订单金额支付经常少1分的问题
最近碰见一个奇怪的问题,商城通过微信支付的订单经常少一分钱,经过排查是PHP浮点运算精度问题造成的 由PHP浮点数运算精度造成的,鸟哥的Bolg有详细的说明.http://www.laruence.c ...
- JSP 连接数据库JDBC有一定的了解
JSP 连接数据库 本章节假设您已经对JDBC有一定的了解.在开始学习JSP数据库访问前,请确保JDBC环境已经正确配置. 首先,让我们按照下面的步骤来创建一个简单的表并插入几条简单的记录: 创建表 ...
- VB.NET的前世今生
[前言]初次见到这个强大的东西.一看名字就没有了陌生感,由于它和我曾经见过的VB肯定有非常多的联系. 俗话说,看人看相,了解看感觉(O(∩_∩)O~~几乎相同这个意思吧). 要想了解VB.net就要从 ...
- 初识Modbus TCP/IP-------------C#编写Modbus TCP客户端程序(一)
转自:http://blog.csdn.net/thebestleo/article/details/52269999 首先我要说明一下,本人新手一枚,本文仅为同样热爱学习的同学提供参考,有不 对的地 ...
- JMeter 通过CSV Data Set Config 中文参数化数据,插入数据库后中文显示乱码,解决办法
问题描述: 1. 需要设置中文参数化,模拟post请求,通过配置元件 - CSV Data Set Config 进行设置. 2. 数据库数据显示乱码(实际数据为 “测试001”) 解决办法: CSV ...