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 ...
随机推荐
- BGP双线的真真假假
BGP双线的真真假假: 国内不少IDC服务商都号称自己是“真正的双线”.“双线单IP”.“全路由双线”,但是,这其中有没有水分?他们都是BGP双线?BGP的门槛真的这么低吗? 首先,要构建真正的BGP ...
- 编程算法 - 求1+2+...+n(构造函数) 代码(C++)
求1+2+...+n(构造函数) 代码(C++) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 求1+2+...+n, 要求不能使用乘除法\for\whi ...
- POJ1195 Mobile phones 【二维线段树】
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 14291 Accepted: 6644 De ...
- JavaScript的toString()
JavaScript toString() 方法 JavaScript Boolean 对象 定义和用法 toString() 方法可把一个逻辑值转换为字符串,并返回结果. 语法 booleanObj ...
- Apatar 学习文档
1. Apatar数据集成简介 Apatar是一个开源跨平台数据集成工具,可以安装和运行在任何机器这有一些类型的用户界面.该工具用于启用批处理数据集成和提供简单的用户界面,这样任何人,不仅仅是技术 ...
- Tomcat9源码分析:BootStrap
概览 BootStrap源码所在的位置是:org.apache.catalina.startup.Bootstrap 这个类是Tomcat项目的启动类,也就是main函数所在的地方,起始tomcat就 ...
- C分配struct变量一个不理解的地方
- python 常用数据结构
#coding=utf- #元组,不可变序列(,) a=(,,,) print(a) a=tuple([,,,])#第二种定义方式 print(a) print(a[]) print(a[:]) #可 ...
- C语言基础知识【数组】
2017年7月11日17:34:05C 数组1.C 语言支持数组数据结构,它可以存储一个固定大小的相同类型元素的顺序集合.数组是用来存储一系列数据,但它往往被认为是一系列相同类型的变量.数组的声明并不 ...
- React antd嵌入百度编辑器(css加载不到等问题,'offsetWidth' of null)
之前有看过一些类似的文章,以为嵌入不会遇到太多坑 结果... 其他不说,先来描述下跳坑的过程 先定义Ueditor.js类,这个和网上版本类似 import React, { Component ...