Ninject 如何在不创建实例的情况下检查给定类型的绑定是否可用
所以我只是想测试我的模块,通常我会用给定的模块创建一个内核,然后尝试获取一个实例,但是这个场景涉及一些模块,如果我可以检查某些模块是否有,那就更好了访问某些绑定(即实现和接口)
有没有什么方法可以检查给定类型的绑定是否可用,而无需创建类的实例(即,我不必确保这些依赖项存在)?
So I m just trying to test my modules, normally i would go and create a Kernel with the given module and then try to get an instance, however this scenario involves a few modules and it would be nicer if I could check that certain modules have access to certain Bindings (ie that implement and interface)
Is there any way to check if a binding for a given type is available without creating and instance of the class (ie so I don't have to make sure those dependencies are there)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该死,当然,我一发布就发现在内核中,有一个 GetBindings() 方法几乎可以满足我的需要。
希望这对某人有帮助
Damn, of course as soon as I posted I found that in the Kernel, there is a
GetBindings()
method that does pretty much what I need.Hope this helps to someone