使用NInject进行布线依赖的选项 [英] Options for wiring dependencies with NInject

查看:91
本文介绍了使用NInject进行布线依赖的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用NInject(最好是2.0),我们有什么选择可以在Web应用程序中连接我们的对象依赖关系?

With NInject (preferably 2.0), what options do we have wrt wiring up our object dependencies in a web application?

可以在XML配置文件中定义它们?

Can they be defined in an XML configuration file?

还是要通过代码完成?

推荐答案

Ninject没有XML配置,对不起,但是我不能提供直接的链接(他们的网站有flash元素),但这里是从 ninject.org

Ninject doesn't have XML configuration, sorry but I can't provide a direct link (cos their site has flash elements), but here is a quotation from ninject.org:


从XML中释放自己

大多数其他.NET依赖注入
框架围绕使用
的XML来声明类型绑定。
而不是强迫你写
麻烦和容易出错的文本,
Ninject用流利的
接口,你可以连接
的应用程序使用
完整的代码。这意味着您可以
利用
IDE和编译器的功能,如代码完成
和类型安全。

Most other .NET dependency injection frameworks are designed around the use of XML to declare type bindings. Rather than forcing you to write cumbersome and error-prone text, Ninject arms you with a fluent interface, which lets you connect the pieces of your application using full-fledged code. This means you can take advantage of the features of the IDE and compiler, like code completion and type-safety.

这篇关于使用NInject进行布线依赖的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆