惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
博客园 - 【当耐特】
博客园_首页
The GitHub Blog
The GitHub Blog
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
博客园 - 三生石上(FineUI控件)
D
Docker
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
小众软件
小众软件
I
InfoQ
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky

博客园 - 福娃

Ubuntu 16.04 LTS更新 程序员如何走出迷茫的困境? PHP vs Python Apache2.4中开通HTTP基本认证 NPM 与 left-pad 事件:我们是不是早已忘记该如何好好地编程? Groovy split竖杆注意 使用Flask-Migrate进行管理数据库升级 Fabric自动部署太方便了 程序员的复仇:11行代码如何让Node.js社区鸡飞狗跳 CAS认证原理图 grails 私有库相关设置 A successful Git branching model String to Date 多种格式转换 IBatis.Net如何支持多个数据库 [django]the story about Django and TurboGears [django]newforms两种方式示例 Since NHibernate 1.2.0, objects are lazy by default - 福娃 [Castle]Castle.Model被Castle.Core代替了 [Castle]Asp.Net中获取Castle容器中的服务的另一方法
[Castle]Castle也范型 - 福娃 - 博客园
福娃 · 2006-12-11 · via 博客园 - 福娃

配置文件如下:

<!-- Core data access services -->
        
<component 
            
id="commondao" 
            service
="RXOA.DataAccess.ICommonDao`1,RXOA.DataAccess"
            type
="RXOA.DataAccess.CommonDao`1,RXOA.DataAccess">
        
</component>

上面这种是一种通用的配置方法,也就是说这种配置可以使用任何类型如:

private ICommonDao<Announce> _commonDao;
        
private ICommonDao<AnnounceType> _typecommonDao;
        
private ICommonDao<ObjectLooker> _objDao;


        
public AnnounceService(ICommonDao<Announce> commonDao, ICommonDao<AnnounceType> typecommonDao,
                               ICommonDao
<ObjectLooker> objDao)
        
{
            
this._commonDao = commonDao;
            
this._typecommonDao = typecommonDao;
            
this._objDao = objDao;
        }

这里有三种不同的类型,只需上面一个配置即可。
你也可以配置制定类型的范型服务

<component 
    
id='int.repos.generic' 
    
service='Namespace.IRepository`1[[System.Int32]], AssemblyName' 
    type
='Namespace.Repository`1[[System.Int32]], AssemblyName' />

更多参考Castle Documention
http://www.castleproject.org/container/documentation/v1rc3/usersguide/genericssupport.html