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 ...
随机推荐
- linux的用户、群组
1. 用户及passwd文件 1) 掌握/etc/passwd文件的功能:存储所有用户的相关信息,该文件也被称为用户信息数据库(Database). 2) /etc/pa ...
- Lua基本函数库 【转】
转自:http://www.cnblogs.com/whiteyun/archive/2009/08/12/1543184.html 基本函数库为Lua内置的函数库,不需要额外装载 assert (v ...
- oracle中把函数的执行权限赋个某个用户
赋权:grant execute on function1 to ucr_dtb1;收回执行权限:revoke execute on function1 from ucr_dtb1; 在ucr_dtb ...
- Cassandra安装和初次使用
Cassandra安装和初次使用 卡珊德拉(Cassandra)又译卡桑德拉.卡珊卓,为希腊.罗马神话中特洛伊(Troy)的公主,阿波罗(Apollo)的祭司.因神蛇以舌为她洗耳或阿波罗的赐予而有预言 ...
- Android控件ListView获取item中EditText值
能够明白,如今没有直接方法能够获得ListView中每一行EditText的值. 解决方式:重写BaseAdapter,然后自行获取ListView中每行输入的EditText值. 大概算法:重写Ba ...
- 【SQLServer2008】之如何导入mdf,ldf文件、导入.mdf文件报错解决问题以及如何获得Authenticated Users 权限
一.如何导入mdf,ldf文件: 链接:http://jingyan.baidu.com/article/09ea3ede21258cc0afde3943.html 二.导入.mdf文件报错解决问题 ...
- 【Atheros】内核调试及网卡加载等问题小结
我做的其他很多工作就比较有针对性了,不是什么大众性的问题,比如加统计代码.实现自己的速率调整算法或者加一些自己的控制什么的,就不再单独介绍了,最后呢再罗列一些小问题,供参考. 1. 加载模块(执行wi ...
- iOS 10 中引入了 Message 框架
WWDC 2016 上最重磅的消息之一就是在 iOS 10 中引入了 Message 框架.开发者现在可以为苹果内置的 Messages 应用开发扩展啦.通过开发一个应用扩展,你可以让用户跟应用在 M ...
- js实现table内 某列的内容进行即时筛选
往往有些时候,我们把数据从数据库读取出来,显示到table里面,而此时来了个新需求,要在一个搜索框内输入关键字,表格的内容进行即时的筛选. 而即时触发进行数据库的查询,再回调显示,就显得慢,拖累服务器 ...
- local variable 'xxx' referenced before assignment(犯过同样的错)
这个问题很囧,在外面定义了一个变量 xxx ,然后在Python的一个函数里面引用这个变量,并改变它的值,结果报错local variable 'xxx' referenced before assi ...