使用 NInject 连接依赖项的选项 [英] Options for wiring dependencies with NInject

查看:21
本文介绍了使用 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?

还是必须通过代码来完成?

Or does it have to be done via code?

推荐答案

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天全站免登陆