Reputation: 55
I'm currently working at a discord bot and the CommandHandler needs an IServiceProvider for the Dependency Injection but I do use Ninject does anyone know a way to retrieve a ServiceProvider from Ninject? So that my binded Modules are inside the ServiceProvider?
Couldn't figure it out myself.
I would appreciate some help :)
Upvotes: 0
Views: 558
Reputation: 411
As corollary of what @Scott said, the interface IKernel
extends IServiceProvider
, so in your RegisterServices
method, you could add a binding like this:
kernel.Bind<IServiceProvider>().ToMethod(ctx => ctx.Kernel);
Upvotes: 0
Reputation: 11
The StandardKernel
implicitly implemented IServiceProvider
interface.
Upvotes: 1