什么是UnityContainer.Resolve超过Activator.CreateInstance的优势在哪里? [英] What is the advantage of UnityContainer.Resolve over Activator.CreateInstance?

查看:241
本文介绍了什么是UnityContainer.Resolve超过Activator.CreateInstance的优势在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始接触团结。我仍然不知道什么其优点。

UnityContainer()解决< T>(),可以返回 已注册为通用型的类型的具体实例 T

我想我也可以使用 Activator.CreateInstance< T>()

激活是一个内置在.NET Framework类,所以我想知道什么样的显着特点的团结是?

解决方案

MSDN指出,这些为统一集装箱的优势:

  
      
  1. 简化对象的创建,特别是对于分层对象结构和依赖
  2.   
  3. 的规定抽象;这使得开发人员能够在运行时还是在配置中指定依赖,简化横切关注点管理
  4.   
  5. 在通过延迟组件配置到容器更大的灵活性
  6.   
  7. 在服务定位能力;这使得客户端存储或缓存容器
  8.   
  9. 实例和类型拦截。
  10.   

这里是链接

I'm just getting started with Unity. I am still wondering what its advantages are.

UnityContainer().Resolve<T>() which can return a concrete instance of the type that is registered for the generic type T.

I think I can also use Activator.CreateInstance<T>().

Activator is a built-in class in the .NET Framework, so I am wondering what the distinct feature for Unity is?

解决方案

MSDN states these as the advantages of Unity Container:

  1. Simplified object creation, especially for hierarchical object structures and dependencies
  2. Abstraction of requirements; this allows developers to specify dependencies at run time or in configuration and simplify management of crosscutting concerns
  3. Increased flexibility by deferring component configuration to the container
  4. Service location capability; this allows clients to store or cache the container
  5. Instance and type interception.

Here's the link.

这篇关于什么是UnityContainer.Resolve超过Activator.CreateInstance的优势在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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