开发者

Ninject - Kernel in static class?

开发者 https://www.devze.com 2023-04-09 19:40 出处:网络
Is it right at all to \"wrap\" a StandardKernel with the required NinjectModules in a static class in a separate, share开发者_运维知识库d library, and use that same library whenever injection is neede

Is it right at all to "wrap" a StandardKernel with the required NinjectModules in a static class in a separate, share开发者_运维知识库d 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)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号