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 ...
随机推荐
- 隐藏VS2013的反馈、通知和登录按钮
Visual Studio 2013的右上角有反馈.通知.登录.快速启动等按钮,在VS2013中没有选项可以设置为隐藏. 打开注册表(开始 -> 运行 -> regedit),展开到以下路 ...
- Hadoop相关资料
http://blog.csdn.net/skywalker_only/article/details/40650427
- spring download
http://maven.springframework.org/release/org/springframework/spring/
- C语言include预处理命令与多文件编译
#include预处理命令几乎使我们在第一次接触C的时候就会碰到的预处理命令,可我现在还不怎么清楚,这次争取一次搞懂. 一.#include预处理指令的基本使用 预处理指令可以将别处的源代码内容插入到 ...
- ARM初学引导_转
一直都在听说ARM有多么好,有多神奇,有多难学.故学它时都兴奋加恐惧.呵呵,我刚好用ARM也有一段时间了.写点东西给ARM的初学者,希望能起到帮助作用. 1,记住:ARM很简单,就如从51转换到PIC ...
- 使用ffmpeg下载m3u8流媒体
安装 编译好的windows可用版本的下载地址(官网中可以连接到这个网站,和官方网站保持同步): http://ffmpeg.zeranoe.com/builds/ 或者: 百度网盘https://p ...
- X264学习1:简介
H.264是视频编码标准. X264是它的开源实现,是视频编码器. 目录 [隐藏] 1 编码器特性 2 输入输出文件类型 2.1 输入 2.2 输出 3 preset和tune系统 3.1 --pr ...
- django学习总结
tips:django官方中文文档(http://python.usyiyi.cn/django/index.html),django基础教程(http://www.ziqiangxuetang.co ...
- #region的作用和注释快捷键
让函数在编辑器中收起来,简洁 #region All MenuItems [@MenuItem("xxx")] public static void Init() { XXXXX; ...
- PHP-Manual的学习----【语言参考】----【类型】
2017年7月17日15:18:02 该看Boolean 布尔类型1.PHP 支持 8 种原始数据类型. 2.四种标量类型: ◦ boolean(布尔型) ◦ integer(整型) ◦ ...