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.