简体   繁体   English

.Net应用程序的IoC和DI框架

[英]IoC and DI framework for .Net applications

Can you please explain how the following three are different in their intent? 您能否解释以下三个在意图上有何不同?

1) Policy Injection Application Block 1)策略注入应用程序块

2) Structure Map IoC 2)结构图IoC

3) Managed Extensibility Framework 3)托管扩展框架

In terms of the common tasks they do, which is simpler/aligned with generics and C# 3.0 ? 就它们执行的常见任务而言,这与泛型和C#3.0比较简单/一致。

Thanks 谢谢

Lijo Lijo

The three libraries frameworks have different indents, but part of the functionality overlap with each other. 这三个库框架具有不同的缩进,但是部分功能彼此重叠。

  1. Policy Injection Application Block: This is basically a framework for integrating crosscutting concerns into your application. 策略注入应用程序块:这基本上是一个将横切关注点集成到您的应用程序中的框架。 For example to implement logging of methods without touching to original class. 例如,在不接触原始类的情况下实现方法的记录。 So it provides aspect oriented programming functionality. 因此,它提供了面向方面的编程功能。
  2. Structur Map IoC: Structur Map is a Dependency Incection / Inversion of Control container . 结构图IoC:结构图是Control容器依存引用 / 反转 The main goal here is to construct and wire objects together in a clean way. 这里的主要目标是以干净的方式将对象构造和连接在一起。 This should result in code which is easier to test and understand. 这将导致代码更易于测试和理解。
  3. MEF's is a extension-system. MEF是一个扩展系统。 It's main goal is to provide a plugin mechanism, where lots of components and plugins can register and discover each other. 它的主要目标是提供一种插件机制,使许多组件和插件可以相互注册和发现。 (like visual-studio addins). (例如visual-studio插件)。

Each library has a different focus. 每个库都有不同的重点。 But often parts of these library overlap. 但是通常这些库的一部分会重叠。 For example. 例如。

  • Lots of dependency injection framework provide some aspect oriented programming capablities, like the Policy Injection Application Block. 许多依赖注入框架提供了一些面向方面的编程功能,例如策略注入应用程序块。 But it's not the focus and therefore not as powerful. 但这不是重点,因此没有那么强大。
  • MEF uses very similar principals to the most IoC-containers (like Structure Map). MEF使用与大多数IoC容器非常相似的原理(如“结构图”)。 And in fact it's also a IoC-container. 实际上,它也是一个IoC容器。 But the focus is on wiring components together. 但是重点是将组件连接在一起。

For example: 例如:

  • You want to implement cross cutting concerns, like logging, security etc. Use the Policy Injection Application Block 您想实现横切关注点,例如日志记录,安全性等。使用策略注入应用程序块
  • You want to structure your application well, so that it's testable and easier to understand? 您是否想要很好地构建应用程序结构,以便对其进行测试并使其易于理解? An IoC-container like StructureMap can help 像StructureMap这样的IoC容器可以提供帮助
  • You want to build a plugin-model for your application? 您想为您的应用程序构建插件模型吗? Take MEF. 拿MEF​​。

And of course, you can mix those technologies. 当然,您可以混合使用这些技术。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM