How to inject an object into a Ninject Module

前端 未结 1 775
生来不讨喜
生来不讨喜 2021-01-21 21:11

I am using Ninject for DI. I have Ninject Modules that bind some services to the Kernel and use binded object in other modules as a service. To clear the situation let\'s see so

1条回答
  •  再見小時候
    2021-01-21 21:42

    You are misunderstanding the purpose of modules. They are there to configure Ninject. They themselves shouldn't have any dependencies at all. The RegisterManager belongs somewhere in a service or startup action of your application. Or probably you have to change the way the permission manager works so that it takes an enumerable of all configured managers instead of registering them. But it's nearly impossible to tell what is best from the question -- just that you are abusing modules for something they are not intended for.

    0 讨论(0)
提交回复
热议问题