问题描述
使用城堡温莎,是有可能宣布一个类型一次,使用此声明的多个ID,而不是写出来全每次研究。
Using Castle-Windsor, is it possible to declare a type once and use this declaration for multiple Ids rather than writing it out in full each time.
例如。我们有一流的Widget实现IFoo的,我们要的钥匙IFoo.A和IFoo.B来从城堡的Widget。我想要做这样的事情
E.g. we have class Widget that implements IFoo and we want the keys "IFoo.A" and "IFoo.B" to get a Widget from Castle. I want to do something like
<id="IFoo.Main"
type="IFoo"
service="Widget"/>
然后
<id="IFoo.A"
giveme="IFoo.Main/>
<id="IFoo.B"
giveme="IFoo.Main/>
感谢。
推荐答案
你的是寻找被转发类型,我相信......看看这些问题:
What your are looking for is forwarded types I believe... take a look at these questions:
- What在温莎城堡组件注册的情况下转发类型
- Does温莎城堡支持通过XML 转发类型
- What are forwarded types in the context of castle windsor component registration
- Does castle windsor support forwarded types via xml
虽然目前不支持在XML配置框的第二个问题,详细介绍了如何通过编写一个简单的工具来做到这一点的答案。
Though not supported out of the box in xml config at the moment the second question has an answer that details how to do this by writing a simple facility.
这篇关于使用温莎城堡配置文件是有可能委托给另一个项目申报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!