控制及反转;依赖注入在.NET FrameworkNET、Framework

由网友(酷似你妈)分享简介:有DI被应用作为建筑原则或设计模式的在.NET Framework本身的任何具体的例子/实例?是否有任何在该框架的类型的(或多个)/ BCL符合IoC的? Is there any specific example/instance of DI being applied as an architectural pr...

有DI被应用作为建筑原则或设计模式的在.NET Framework本身的任何具体的例子/实例?是否有任何在该框架的类型的(或多个)/ BCL符合IoC的?

Is there any specific example/instance of DI being applied as an architectural principle or design pattern in the .NET Framework itself? Do any (or many) of the types in the framework/BCL conform to IoC?

基于C#中的类型名称和简要说明/解释将是巨大的!

The type names and a brief illustration/explanation based in C# would be great!

此将复方需要的DI注入设计原理作为最佳实践...,因为它是从基部框架本身中收集

This would compund the need for DI infused design principle as a best-practice...as it is gleaned from the base framework itself.

我要重申,我不是在寻找的IoC / DI框架的可是作为的IoC / DI 在的框架。

I reiterate, I am not looking for IoC/DI Frameworks BUT for IoC/DI IN the framework.

编辑:只是想获得更多的实例/例子......因此,赏金

Just wanted to get more instances/examples ... hence the bounty!

推荐答案

在一般不会有大量的DI在BCL例子 - 也许是因为BCL是一个相当自足的框架,DI是更多应用程序架构的关注。不过,这里有一些例子,我能找到为止。

In general there aren't a lot of examples of DI in the BCL - perhaps because the BCL is a rather self-contained framework, and DI is more of an application architecture concern... However, here are some examples I've been able to find so far.

构造器注入

有没有构造器注入的BCL的例子很多。最好的候选人

There are not many examples of Constructor Injection in the BCL. The best candidates are

System.IO.StreamWriter 就是System.IO.StreamReader

属性注入

System.ComponentModel.IComponent.Site

我们也看到在Workflow Foundation中的 WorkflowRuntime.AddService 和相关方法的变化,虽然你可能会认为这是更接近方法注入。

We also see a variation in Workflow Foundation's WorkflowRuntime.AddService and related methods, although you might argue that this is closer to Method Injection.

方法注入

System.ComponentModel.Design.IDesigner.Initialize System.ComponentModel.TypeConverter(很多方法都ITypeDescriptorContext) System.Web.Mvc.IModelBinder.BindModel(从ASP.NET MVC)

周围语境

System.Threading.Thread.CurrentPrincipal System.Threading.Thread.CurrentCulture System.Threading.Thread.CurrentUICulture System.Diagnostics.Trace.Listeners

FWIW,我画了从我即将出版的新书。

FWIW, I drew these examples from my upcoming book.

阅读全文

相关推荐

最新文章