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

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
量子位
小众软件
小众软件
C
Cybersecurity and Infrastructure Security Agency CISA
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tenable Blog
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
T
Threat Research - Cisco Blogs
Latest news
Latest news
Spread Privacy
Spread Privacy
C
Cyber Attacks, Cyber Crime and Cyber Security
NISL@THU
NISL@THU
T
Tor Project blog
Hacker News: Ask HN
Hacker News: Ask HN
V2EX - 技术
V2EX - 技术
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
K
Kaspersky official blog
Cyberwarzone
Cyberwarzone
博客园 - 叶小钗
博客园 - 聂微东
Last Week in AI
Last Week in AI
爱范儿
爱范儿
腾讯CDC
博客园 - Franky
美团技术团队
J
Java Code Geeks
O
OpenAI News
L
Lohrmann on Cybersecurity
Simon Willison's Weblog
Simon Willison's Weblog
有赞技术团队
有赞技术团队
T
Threatpost
G
GRAHAM CLULEY
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
宝玉的分享
宝玉的分享
I
Intezer
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
S
Security @ Cisco Blogs
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
Stack Overflow Blog
Stack Overflow Blog
Scott Helme
Scott Helme
H
Hacker News: Front Page
Cloudbric
Cloudbric

博客园 - 福娃

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