views:

244

answers:

2

I am looking for a way to do something like this with Ninject :

// Sample from the Unity application block
IMyService result = myContainer.Resolve<IMyService>("Data");

( from http://msdn.microsoft.com/en-us/library/cc440957.aspx )

Is it possible?

A: 

AFAIK there is no way to do that directly in Ninject, but you can use Contextual Binding instead.

Mauricio Scheffer
+6  A: 

Ninject 2.0 has this capability:

Bind<IMyService>().To<MyServiceA>().Named("Data");
Bind<IMyService>().To<MyServiceB>().Named("SomethingElse");

kernel.Get<IMyService>("Data"); // will return MyServiceA
Nate Kohari