为什么IoC会被称为容器

为什么IoC会被称为容器

本文介绍了为什么IoC会被称为容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解容器可以容纳其他来源的对象并处理这些对象上的东西......其中IoC容器看起来像处理功能而不是真正包含任何东西。  

I understand containers to hold objects of other sources and handle things on these objects... where IoC containers seem like they handle functionality instead and are not really containing anything.  

推荐答案




嗨    tvance929,



据我所知,IoC允许您将程序解耦为彼此不了解的单独组件。最常见的IoC版本之一是




在依赖注入中,每个组件都必须声明执行所需的依赖项列表这是任务。在运行时,一个称为IoC容器的特殊组件(通常)会在这些组件之间执行绑定。它试图为已发布的
组件依赖项提供值。



IoC Container(a.k.a. DI Container)是一个实现自动依赖注入的框架。它管理对象创建及其生命周期,并为类注入依赖关系。



为IoC容器创建和查找依赖对象,并注入IoC容器进入复合对象。 IoC有一个特殊的容器来创建这些对象,也就是说,Ioc容器控制对象的创建,并控制
外部资源获取(包括对象和文件等),容器也需要管理这些对象的生命周期。



依赖性倒置原则,IoC Container&依赖注入(第2部分)
$




最好的问候,



Yong Lu

 



Hi   tvance929,

As far as I know, the IoC allows you to decouple your program into separate components that don't know about each other. One of the most common versions of IoC isDependency injection.

In Dependency Injection each component must declare a list of dependencies required to perform it's task. At runtime a special component (generally) called an IoC Container performs binding between these components. It tries to provide values for published component dependencies.

IoC Container (a.k.a. DI Container) is a framework for implementing automatic dependency injection. It manages object creating and its life time and also injects dependencies to the class.

Creating and finding dependent objects is given to the IoC container, and the IoC container is injected into the composite object. IoC has a special container to create these objects, that is, the Ioc container controls the creation of the object, and controls the external resource acquisition (including the object and Files, etc.), the container also needs to manage the life cycle of these objects.

Dependency Inversion Principle, IoC Container & Dependency Injection (Part - 2)


Best Regards,

Yong Lu
 


这篇关于为什么IoC会被称为容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 13:32