Summary
We studied the most common DI patterns and antipatterns related to Ninject. Multibinding means binding a single service type to multiple concrete types and has two scenarios of the Plugin model and contextual binding. Providers are a kind of factories that are specialized for Ninject to be used for creating new instances of resolved types. We can create our own providers by deriving from the Provider<T> class. A Factory method is a substitute for Provider, where the activation logic is short and simple and instantiation of the service type is not as simple as calling the constructor of the implementation. Introducing a dependency as Lazy<dependency> informs Ninject to defer instantiation of that dependency whenever that dependency is requested. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access