Spring.net (1) concept-control reversal (also known as dependency injection)

Source: Internet
Author: User
Tags xml attribute

As an application framework, Spring.net provides many flexible and rich functions (such as dependency injection, aop, data access abstraction, and asp.net extension) for enterprise-level. net applications ).

Inversion of Control (IoC) is a design principle in object-oriented programming. It can be used to reduce the Coupling Degree between computer code. The most common method isDependency Injection(Dependency Injection, shortDI(Dependency Lookup ). When an object is created, the external entity of all objects in a control system transmits the reference of the object to it. It can also be said that the dependency is injected into the object.

 

Personal Understanding: controls the instantiation of object holding relationships based on the parent-child inheritance, interface or abstract Implementation of objects in the object-oriented model.

Instance:

There is a pet:

  name { ; 

 

Puppies:

   name { ;  

 

Persons:

  

    name { ;  Pet pet { ; 

 

A simple spring framework:

Project Reference: spring. core-the basis of the entire framework.Dependency InjectionFunctions

Spring. AOP-Support for Aspect-oriented programming (aop)

Spring. Data -- a defines an abstract Data access layer that can be used to access Data across various Data access technologies (from ADO. NET to various orm.

Project configuration file: app. config

  

                                                              

 

The objects. xml Attribute is always copied, otherwise the <resource uri = "file: // objects. xml"> </resource> configured above cannot be found.

                      

 

In the console program:

 = ctx.GetObject() 

 

Call:

 IApplicationContext ctx =  Main(

 

Console output:

Wangcai

-------------------------
OK. The first ioc example ends.
To put it simply, spring.net is like an instantiation factory that injects instance objects and assigns attribute values to instance objects.
  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.