Multi binding and contextual binding
In the previous chapter, we saw how Ninject can resolve dependency types in single binding situations, that is, each service type is bound only to a single implementation type. However, there are situations where we need to bind an abstract service type to multiple implementations, which is called as multi binding. Multi binding has two scenarios. The first one is the plugin model implementation and the other one is contextual binding, which we will discuss in this section.
Implementing the plugin model
The plugin model allows an application to be extremely extensible without modifying its source code. In the following example, we will implement a Music Player application, which uses codec plugins in order to ...
Get Mastering Ninject for Dependency Injection now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.