0
有接口...在Castle Windsor中,如何注册泛型接口的许多实现中的一个实现泛型类型的实现?
IThing
IWrapping<IThing>
...通过Things
实现...
Cookie : IThing
Carmel : IThing
Chocolate : IThing
...和Wrappings
他们...
Paper <TThing> : IWrapping<TThing> where TThing is IThing
Foil <TThing> : IWrapping<TThing> where TThing is IThing
...我选择一个实现Wrapping
来运行该应用程序,忽略其他。要注册选择了所有已知的IThing
实现我现在必须列出所有这些Wrapping
:
Component.For<IWrapping<Cookie>>() .ImplementedBy<Paper<Cookie>>(),
Component.For<IWrapping<Carmel>>() .ImplementedBy<Paper<Carmel>>(),
Component.For<IWrapping<Chocolate>>().ImplementedBy<Paper<Chocolate>>(),
怎样一个寄存器所有的人都在一次?
Component.For<IWrapping<IThing>>()
.ImplementedBy<Paper<ALL_FOUND_IMPLEMENTATIONS_OF_ITHING>>(), // One place to switch between Paper and Foil