Ninject - Kernel in static class?

点点圈 提交于 2019-12-13 13:49:11

问题


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)?

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/7628365/ninject-kernel-in-static-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!