Ninject 自动连线
一些 IOC 容器具有所谓的基于约定的自动装配,例如,IProductRepository 映射到 ProductRepository,而无需您进行任何手动装配。
Ninject有这样的事吗?
Some of the IOC containers have what's called auto-wiring based on conventions, for e.g., IProductRepository maps to ProductRepository without any manual wiring on your part.
Is there such a thing with Ninject?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
复制自 @Pete Montgomery 评论
copied from @Pete Montgomery comment
Ninject 附带了基于约定的配置的扩展。但您仍然需要配置您的约定。请参阅 https://github.com/ninject/ninject.extensions.conventions 语法有3.0.0 发生了变化,但变得更加强大。以下将为系统中的所有类添加绑定。但通常您需要针对不同类型的类使用其中一些约定(例如,服务是单例,......)
Ninject comes with an extension for convention based configuration. But you still need to configure your convenions. See https://github.com/ninject/ninject.extensions.conventions The syntax has changed for 3.0.0 but has become much more powerful. The following would add bindings for all classes in your system. But normally you want several of these conventions for different kind of classes (e.g. services are singletons, ....)