Reputation: 46740
I have a binding of an interface to a concrete class thus
_ninjectKernal.Bind<IAuctionContext>().To<AuctionContext>()
What I want to do in my code is get the concrete class for the interface IAuctionContext
. So I want to do something like this
IAuctionContext context = .GetBinding();
Where context
will be of type AuctionContext
.
Is this possible. I've done similar stuff with StructureMap in the past.
Upvotes: 2
Views: 1238
Reputation: 35399
// get access to the "container"
IKernel kernel = new StandardKernel(.....);
// use kernel, as you would any other container
var context = kernel.Get<IAuctionContext>();
Note - If you are using dependency injection you should shy away from calling Get( ... )
in "Kernel" (or Container.GetInstance( ... )
in StructureMap) directly.
Upvotes: 4