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

推荐订阅源

N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
爱范儿
爱范儿
量子位
博客园 - 聂微东
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
GbyAI
GbyAI
MyScale Blog
MyScale Blog
IT之家
IT之家
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Hugging Face - Blog
Hugging Face - Blog
The Register - Security
The Register - Security
Microsoft Security Blog
Microsoft Security Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
雷峰网
雷峰网
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
博客园 - 叶小钗
D
DataBreaches.Net
B
Blog
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
腾讯CDC
T
Threat Research - Cisco Blogs
SecWiki News
SecWiki News
Martin Fowler
Martin Fowler
D
Docker
Cisco Talos Blog
Cisco Talos Blog
T
Tenable Blog
Webroot Blog
Webroot Blog
宝玉的分享
宝玉的分享

博客园 - 福娃

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