【发布时间】:2015-03-11 03:45:07
【问题描述】:
我有两个用于相同服务类型的组件。在运行应用程序时,Castle 总是加载第一个组件。例如,我有一个指向不同数据库的IDbConfiguration 服务,以及IDbconfiguration 的两个组件:
<component id="DbConfig"
service="Maloft.Keryx.Infrastructure.RepositoryFramework.IDbConfiguration, Keryx.Infrastructure"
type="Maloft.Keryx.Infrastructure.RepositoryFramework.DbConfiguration, Keryx.Infrastructure"
lifeStyle="PerWebRequest"/>
<parameters>
<connectionName>kerxy</connectionName>
</parameters>
<component id="DbReportingConfig"
service="Maloft.Keryx.Infrastructure.RepositoryFramework.IDbConfiguration, Keryx.Infrastructure"
type="Maloft.Keryx.Infrastructure.RepositoryFramework.DbConfiguration, Keryx.Infrastructure"
lifeStyle="PerWebRequest">
<parameters>
<connectionName>kerxyReporting</connectionName>
</parameters>
</component>
组件PlayerRepository 依赖于DbReportingConfig,PlayerDomainService 依赖于PlayerRepository,但是当我解决这些服务中的任何一个时,它们总是加载第一个DbConfig。
更改 xml 文件中的顺序显示 IDbConfiguration 的第一个组件是每次使用的组件。我为这两个组件设置了不同的 Id,为什么总是加载第一个?
【问题讨论】:
标签: components castle