IoC - Multiple implementations support for a single interface

后端 未结 7 1454
清歌不尽
清歌不尽 2020-12-30 02:50

I am wondering why .Net IoC containers do not easily support multiple implementations for a single interface! May be I am wrong, but as far I have seen, frameworks like Nin

相关标签:
7条回答
  • 2020-12-30 03:23

    Your premise is wrong.

    Windsor quite happily accepts registrations of multiple implementations of the same service. In addition to the named component resolution support mentioned by GSerjo, in Windsor (by default), the first registered implementation will win but you can override this by using IsDefault() method when registering an alternative implementation. Please see http://docs.castleproject.org/Windsor.Registering-components-one-by-one.ashx for more details.

    If you wish to exercise more control over the selection from multiple implementations you can create an IHandlerSelector implementation to do so. Please see http://stw.castleproject.org/Windsor.Handler-Selectors.ashx for more details.

    0 讨论(0)
提交回复
热议问题