Does Ninject Conventions only work for public classes?

后端 未结 1 895
你的背包
你的背包 2021-01-24 13:08

I started using Ninject for my project, to automatically bind all subclasses of an abstract class. The binding for this is -- nice and easy -- as follows:

kernel         


        
相关标签:
1条回答
  • 2021-01-24 13:57

    Put a .IncludingNonPublicTypes() before the .SelectAllClasses() and your bindings will also work for internal classes.

    Also see this question: Cannot get Ninject.Extensions.Conventions to work

    I don't think it's about security. I guess it's about design and maybe about performance: choosing from only the public types takes less time than choosing from all types.

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