控制反转与.NET [英] Inversion of Control with .net

查看:100
本文介绍了控制反转与.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是罕见的,我听说使用控制的反转(IoC)与.net原则的人。我有一些朋友说,与Java的工作,使用了很多IoC和Spring和PicoContainer的。

It's rare that I hear someone using Inversion of Control (Ioc) principle with .Net. I have some friends that work with Java that use a lot more Ioc with Spring and PicoContainer.

据我所知从您的代码删除依赖的原则......但我有一个疑问,这是好多了。

I understand the principle of removing dependencies from your code... but I have a doubt that it's so much better.

为什么净程序员不使用(或使用更少)这些类型的框架?如果你这样做,你真的找到一个长期的积极影响?

推荐答案

很多人使用国际奥委会在.NET中,有几个可用的框架,以协助国际奥委会使用。您可能会较少看到它在事物的WinForms的一面,因为它很难只是让容器线都在一起,当你正在设计在Visual Studio中的形式,但我可以说,服务器端.NET应用程序,我在那里至少工作国际奥委会是非常成功的。

Lots of people use IOC in .NET, and there are several frameworks available to assist with using IoC. You may see it less in the WinForms side of things, because it's harder to just let the container wire everything together when you are designing forms in Visual Studio, but I can say that for server-side .NET applications, where I work at least, IoC is used very successfully.

为什么.NET使用它?对于您使用它在其他地方一样的道理。我喜欢2个最大的事情是:

Why use it in .NET? For the same reason you use it everywhere else. The 2 biggest things I like are:


  • 设计为国际奥委会倾向于强制良好的编码习惯 - 设计到界面,低耦合,高内聚。这也导致了很容易单元测试类。

  • 系统配置往往可以改变而无需重新编译。

其他的一些讨论帖提供的不同的IoC / DI框架.NET:

Some other posts discussing the different IoC/DI frameworks available for .NET:

  • Which C#/.net Dependency Injection frameworks are worth looking into?
  • Which Dependency Injection Tool Should I Use?

这篇关于控制反转与.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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