Two critical attributes in Abpbootstrapper: Iiocmanager and Iabpmodulemanager
1 Public classabpbootstrapper:idisposable2 {3 /// <summary>4 ///Gets Iiocmanager Object used by this class.5 /// </summary>6 PublicIiocmanager Iocmanager {Get;Private Set; }7 8 /// <summary>9 ///Is this object disposed before?Ten /// </summary> One protected BOOLisdisposed; A - PrivateIabpmodulemanager _modulemanager; - //......... the}
View Code
Iiocmanager internally wraps a castle Dependency injection container IWindsorContainer (ABP uses the Castle Windor framework, which is based on this framework to do some encapsulation),
All types of registrations, parsing and the subsequent implementation of the AOP mechanism of interceptors are registered in the container, the specific registration and parsing functions are included in their parent interface Iiocregistrar and Iiocresolver
1 Public InterfaceIiocmanager:iiocregistrar, Iiocresolver, IDisposable2 {3 /// <summary>4 ///Reference to the Castle Windsor Container.5 /// </summary>6IWindsorContainer Ioccontainer {Get; }7 8 /// <summary>9 ///Checks Whether given type is registered before.Ten /// </summary> One /// <param name= "type" >Type to check</param> A New BOOLisregistered (type type); - - /// <summary> the ///Checks Whether given type is registered before. - /// </summary> - /// <typeparam name= "T" >Type to check</typeparam> - New BOOLIsregistered<t>(); +}
View Code
The class diagram of the Iiocregistrar class is as follows:
1.AddConventionalRegistrar,
2.RegisterAssemblyByConvention (Assembly Assembly),
3.RegisterAssemblyByConvention (Assembly Assembly, conventionalregistrationconfig config)
The above three methods require special attention:
The first method, Addconventionalregistrar, is a private generic collection list<iconventionaldependencyregistrar> the registration mechanism to Iocmanager, which is not very good to understand is simply to set the injection mode of the dependency injection module,
Usually all of the module classes are called in a pre-initialization method to determine which types need to be registered (without having to call them if not).
For example, in the ABP assembly, the Basicconventionalregistrar implementation is to search for and register all implemented itransientdependency in the specified assembly, Isingletondependency and Iinterceptor classes are registered in the dependent container,
Second, the third method executes the true registration logic,
Usually called in the initialization method of a specific module, passing in the assembly to which the current module belongs,
Iteration List<iconventionaldependencyregistrar> registers the current assembly as a parameter,
Second, the third method differs in that the third method has more than one conventionalregistrationconfig parameter to determine whether it also needs to search the current program and the Iwindsorinstaller implementation class to register, which is required by default.
Iabpmodulemanager is primarily used to manage all modules by default, which is a single assembly (one module for each assembly), which is used primarily to search for all module and their dependent module, The Preinitialize method of all module is executed first, all the initialize are executed, and all postinitialize are executed. The shutdown method that executes all of the specific module sequentially reverses the shutdownmodules of the Iabpmodulemanager.
ABP Framework launches core class from Source Learning--ABP Framework Abpbootstrapper (2)