配置文件如下:
你也可以配置制定类型的范型服务
更多参考Castle Documention
http://www.castleproject.org/container/documentation/v1rc3/usersguide/genericssupport.html
<!--
Core data access services
-->
< component
id ="commondao"
service ="RXOA.DataAccess.ICommonDao`1,RXOA.DataAccess"
type ="RXOA.DataAccess.CommonDao`1,RXOA.DataAccess" >
</ component >
上面这种是一种通用的配置方法,也就是说这种配置可以使用任何类型如:
< 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;
}
这里有三种不同的类型,只需上面一个配置即可。
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' />
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