简体   繁体   English

Ninject - 静态类中的内核?

[英]Ninject - Kernel in static class?

Is it right at all to "wrap" a StandardKernel with the required NinjectModule s 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)? 是否正确使用所需的NinjectModule在一个单独的共享库中的静态类中“包装”一个StandardKernel并在需要注入时使用相同的库(而不是每次都实例化一个新内核)?

Edit: I am trying to use Ninject from within the WCF service I am developing at the moment. 编辑:我正在尝试从我正在开发的WCF服务中使用Ninject。

(Please bear with me if what I am saying is completely rubish since I just started learning about DI and IoC containers) (如果我刚开始学习DI和IoC容器,我说的话完全不好意思,请耐心等待)

See https://github.com/ninject/ninject.extensions.wcf . 请参阅https://github.com/ninject/ninject.extensions.wcf This extension will create the WCF service using the Ninject kernel. 此扩展将使用Ninject内核创建WCF服务。 That way you can use constructor injection instead of using the Service Locator pattern. 这样您就可以使用构造函数注入而不是使用Service Locator模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM