IOC learning of DOTNET framework

Source: Internet
Author: User

Now there are more open-source frameworks on DOTNET, mostly Java version conversion. It seems that Java has accumulated a lot in terms of design ideas and mature frameworks.
Currently, there are not many available items: picocontainer/nanocontainer in IOC, and nhibiner in data persistence (Dev xop requires a knife ). Most of the others are in Alpha. For example, springnet, we plan to implement IOC and AOP first, but we still cannot release.
Even the published picocontainer for. Net gives a person the feeling of being a child of a child. There are only a few initial entry-level documents, just a few words. The list is updated frequently. Unfortunately, it is only for Java. It seems that in the Near stage, we can only catch up with the Java ass.
In any case, the download is actually the only criterion for verifying truth. Martin Fowler has already elaborated on the IOC (he thinks dependency injection is more appropriate) Framework Theory in his article (http://martinfowler.com/articles/injection.html, it also compares the advantages and disadvantages of several methods for implementing lightweight IOC. A thousand words can be summed up as "Configuring and using components ".
Separation, and is completed by the Framework. "It is really attractive.
According to the example, write two classes, Class A references Class B, but class A does not Code , But there is a reference parameter for Class B in the constructor. Register these two classes with the Framework.
Imutablepicocontainer Pico = New Defaultpicocontainer ();
Pico. registercomponentimplementation (typeof (B ));
Pico. registercomponentimplementation (typeof ());
The following describes how to use Class.
A A = (a) Pico. getcomponentinstance (typeof ());
A. anyproduce (); // call a method of.
The above Code does not contain the instantiation code of Class B, but class B does. Magic.
Follow the F11 trace, bend around, and finally find constructor. Invoke (parameters); this code. A simple process can be described.
1. register the class type-Save the class information of this class to a hashtable
2. When obtaining an instance of a class:
Obtain the constructor list of A Class Based on class information. Select a constructor based on input parameters and construct it using reflection.
Class. If a parameter is a class reference, repeat this process. Well, with expression stack parsing algorithm 1
Sample.

it seems that the application can be started quickly, or even directly inserted and used in the project.
but there are still many problems. Which layer is used? How to combine with nhib.pdf? What are the requirements for Class Design in our project when we use it? Can the component assembly of our project be realized directly with it?
the study will continue tomorrow.

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.