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 ...
随机推荐
- java数字签名算法之RSA
© 版权声明:本文为博主原创文章,转载请注明出处 实例 1.项目结构 2.pom.xml <project xmlns="http://maven.apache.org/POM/4.0 ...
- hdu 3172 Virtual Friends(并查集,字典树)
题意:人与人交友构成关系网,两个人交友,相当于两个朋友圈的合并,问每个出两人,他们目前所在的关系网中的人数. 分析:用并查集,其实就是求每个集合当前的人数.对于人名的处理用到了字典树. 注意:1.题目 ...
- 在freemarker文件中,html标签获取后台的值
1.<#assign a='3333' /> 2.<input type="text" id="name" name="name&q ...
- Android Studio 使用笔记:在图形界面使用 Gradle 配置项目所需jar包
在 Android Studio 中使用第三方 jar 包,可以直接下载后添加到项目中,也可以使用 Gradle 配置进行管理.图形界面下十分简单. 点击下图中间的图标,或者选中 Model ,按F4 ...
- linux系统寻找僵尸进程
1. 用top命令来查看服务器当前是否有僵尸进程. 2. 用ps和grep命令寻找僵尸进程 $ ps -A -ostat, pid, ppid, cmd | grep -e '^[Zz]' 命令解释: ...
- cocos2d-x 2.x 支持多个方向屏幕翻转
主要改动 RootViewController.mm 的 supportedInterfaceOrientations 方法 1.四个方向 UIInterfaceOrientationMaskAll ...
- git 常用使用命令
http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html http://www.open-open.com/lib/view/open14 ...
- Asp.Net MVC3中如何进行单元测试?
下面我们就以一个示例演示一下如何进行单元测试? public Model.UserInfo UpdateEntity(Model.UserInfo entity) { db.UserInfo.Atta ...
- Wrapper配置详解及高级应用
将一个简单的程度如HelloWorld 的应用包装秤Wrapper 服务并不复杂,甚至可以认为非常简单.但是实际项目应用过程中我们的程序一般较庞大,运行环境也较复杂. 通过Wrapper 配置文件 ...
- OLTP和OLAP
1 OLTP和OLAP online transaction processing,联机事务处理.业务类系统主要供基层人员使用,进行一线业务操作,通常被称为联机事务处理. online analyti ...