Ninject-静态类中的内核?

Ninject-静态类中的内核?

问题描述:

在单独的共享库中的静态类中将"StandardKernel"与所需的NinjectModule包装"在一起,并在需要注入时使用同一库(而不是实例化新内核)是否完全正确?每次)?

Is it right at all to "wrap" a StandardKernel with the required NinjectModules in a static class in a separate, shared library, and use that same library whenever injection is needed (instead of instantiating a new kernel everytime)?

我正在尝试从目前正在开发的WCF服务中使用Ninject.

I am trying to use Ninject from within the WCF service I am developing at the moment.

(自从我刚开始学习DI和IoC容器以来,如果我所说的话完全是鲜红的,请与我包容)

(Please bear with me if what I am saying is completely rubish since I just started learning about DI and IoC containers)

请参见 https://github .com/ninject/ninject.extensions.wcf .该扩展将使用Ninject内核创建WCF服务.这样,您可以使用构造函数注入,而不是使用Service Locator模式.

See https://github.com/ninject/ninject.extensions.wcf . This extension will create the WCF service using the Ninject kernel. That way you can use constructor injection instead of using the Service Locator pattern.