Module of ABP

Source: Internet
Author: User

ABP's Module ABP reflection

Why is reflection first, because the module management of ABP is basically to traverse all the assemblies, then filter out the derived classes of abpmodule and then load in the order of relations.

ABP's encapsulation of reflection focuses on the assembly (Assembly) and the Class (type). The Iassemblyfinder and Itypefinder two interfaces are defined separately in the system, and the two interfaces are mainly used for assembly and class lookups.

Iassemblyfinder only provides a method Getallassemblies (), From the implementation class Currentdomainassemblyfinder of Iassemblyfinder, it can be seen that the function of this method is to get all the assemblies under the current application domain.

View Code

The Itypefinder interface provides two method Find,findall, both of which look for all assemblies under all current application domains. The ABP provides the default implementation class Itypefinder for Itypefinder, which has a private method getalltypes with a Iassemblyfinder field assemblyfinder. The Find,findall method is to re-filter the results of the getalltypes return.

View Code

Protagonist Abpmodule

Abpmodule is an abstract class, and all modules are his derived classes. Abpmodule provides preinitialize,initialize,postinitialize,shutdown four non-parametric return value method, from the name can be seen Abpmodule life cycle is divided into four parts, Where initialization is divided into three parts.

Two properties

Protected internal Iiocmanager Iocmanager {get; internal set;}

Protected internal iabpstartupconfiguration Configuration {get; internal set;}

The set methods of both properties are not exposed outside the assembly, so it is possible to judge that both properties are assigned by the ABP system itself. Look at Iocmanager, for this system core Dependency Injection container manager, there should be only one, so it should be a reference to Iocmanager.instance (this part will be embodied in the following).

For the configuration property, there is no specific view of the configuration section, so don't dwell on it. But from the name, it should provide some configuration information to Abpmodule.

Module dependencies

When the initialization of a module requires additional modules, it is necessary to specify its dependent modules. The dependsonattribute is defined in the ABP to come out of the dependencies between the modules.

View Code

Dependsonattribute only provides a type of array property dependedmoduletypes, which specifies the dependency abpmodule for the current module. Depending on the module is also abpmodule type, I do not know why ABP did not do type judgment.

Abpmoduleinfo and Abpmodulecollection

Abpmoduleinfo is the abstraction of the module, and Abpmodulecollection is the collection of Abpmoduleinfo, which stores all the module information of the system. Where Abpmodulecollection provides the Getsortedmodulelistbydependency method, the main function of this method is to get the Abpmoduleinfo collection sorted by dependency. Listextensions between the specific implementations of the sort.

Modulefinder

Imodulefinder and its implementation class Defaultmodulefinder, mainly the audit of all the module classes in the application domain (that is, abpmodule non-abstract derived classes).

Abpmodulemanager

The main function of Abpmodulemanager is to find all the Abpmodule under the application domain, then instantiate, initialize, and destroy the modules.

Abpmodulemanager provides initializemodules and shutdownmodules to manage the life cycle of all modules.

Specification of ABP initialization of modules

For this Part I have directly quoted Yangming's article. Http://www.cnblogs.com/mienreal/p/4537522.html

Entrance to ABP

Iocmanager and Abpmodulemanager are the managers that rely on injection and system modules, then what drives these two system cores. In the source code, the point is directed at the Abpbootstrapper.

View Code

Because Abpbootstrapper implements the IDisposable, Abpbootstrapper itself only provides the Initialize method to initialize the system, and then implement the Dispose method to shut down the system.

You have provided your own HttpApplication derived class abpwebapplication in the ABP. There is a Abpbootstrapper attribute, and then the Abpwebapplication constructor directly instantiates Abpwebapplication, Abpbootstrapper is initialized in application, The abpbootstrapper is shutdown in Application_End.

View Code

Module of ABP

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.