I\'ve recently been trying to learn IoC, and have a couple questions based on the following code:
public class WarriorModule : NinjectModule
{
public
I recently addressed this topic from a more general viewpoint. The bottom line is that there's a tendency for loosely coupled code to produce an overabundance of 1:1 interfaces. This is contrary to the Reused Abstractions Principle.
However, this is more of an application design issue than it's an issue regarding particular DI Containers. While I don't know Ninject, all other containers I've ever worked with (Castle Windsor, StructureMap, Spring.NET, Autofac, Unity, and even MEF) can map multiple implementations to the same interface. How they do this differ slightly, but I cover all of them in part IV of my book - unfortunately, Ninject is not covered in the book.
A good IoC container should not change the way interfaces are used:
Ninject allows using interfaces this way using two different concepts:
Conditional bindings: If several classes implement the same interface you have to specify which implementation is used in which case. This is done using conditions:
Bind<IWeapon>().To<Sword>().When(ctx => TodayIsSunday());
Bind<IWeapon>().To<Dagger>().When(ctx => !TodayIsSunday());
Multiple Interfaces: See my blogpost http://www.planetgeek.ch/2010/12/08/ninject-extension-contextpreservation-explained/