国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

AbpApplication級別的生命周期

2019-11-14 14:26:26
字體:
來源:轉載
供稿:網友

本篇級別: 中高級篇,假設各位知道Abp是什么, Abp里面的基本的概念及用法(想了解基本概念的可在這里學習: http://www.survivalescaperooms.com/mienreal/p/4358806.html)

AbpWebapplication

AbpWebApplication是需要我們的Global.cs里面的HttpApplication繼承他, 初始化分兩個階段

構造方法AbpWebApplication()

在這個方法里面,做了非常重要但是很簡單的事, 通過 AbpBootstrapper類庫,間接實例化了IocManager.Instance, 并且注冊了IocManager,IIlocManager,IIocRegistrar, IIocResolver做了注冊,

也就是這一步完成之后,IocManager.Instance.Reslove只能解析上面的四個類型, 其他類型到目前為止,還一個都沒有注冊.

 

Application_Start(object sender, EventArgs e)方法

a. 注冊了IAssemblyFinder, 關聯到了WebAssemblyFinder類庫, 猜主要是用來尋找相關類庫, 看其代碼主要是獲取當前bin目錄下的所有dll組件,并跟當前已加載的 Assembly做比較,最后返回當前程序已加載的dll, 忽略未加載的.

b. AbpBootstrapper初始化,

b.1 IocManager.IocContainer.Install(new AbpCoreInstaller());
Component.For<IUnitOfWorkDefaultOptions, UnitOfWorkDefaultOptions>().ImplementedBy<UnitOfWorkDefaultOptions>().LifestyleSingleton(),                Component.For<INavigationConfiguration, NavigationConfiguration>().ImplementedBy<NavigationConfiguration>().LifestyleSingleton(),                Component.For<ILocalizationConfiguration, LocalizationConfiguration>().ImplementedBy<LocalizationConfiguration>().LifestyleSingleton(),                Component.For<IAuthorizationConfiguration, AuthorizationConfiguration>().ImplementedBy<AuthorizationConfiguration>().LifestyleSingleton(),                Component.For<IFeatureConfiguration, FeatureConfiguration>().ImplementedBy<FeatureConfiguration>().LifestyleSingleton(),                Component.For<ISettingsConfiguration, SettingsConfiguration>().ImplementedBy<SettingsConfiguration>().LifestyleSingleton(),                Component.For<IModuleConfigurations, ModuleConfigurations>().ImplementedBy<ModuleConfigurations>().LifestyleSingleton(),                Component.For<IEventBusConfiguration, EventBusConfiguration>().ImplementedBy<EventBusConfiguration>().LifestyleSingleton(),                Component.For<IMultiTenancyConfig, MultiTenancyConfig>().ImplementedBy<MultiTenancyConfig>().LifestyleSingleton(),                Component.For<ICachingConfiguration, CachingConfiguration>().ImplementedBy<CachingConfiguration>().LifestyleSingleton(),                Component.For<IAuditingConfiguration, AuditingConfiguration>().ImplementedBy<AuditingConfiguration>().LifestyleSingleton(),                Component.For<IAbpStartupConfiguration, AbpStartupConfiguration>().ImplementedBy<AbpStartupConfiguration>().LifestyleSingleton(),                Component.For<ITypeFinder>().ImplementedBy<TypeFinder>().LifestyleSingleton(),                Component.For<IModuleFinder>().ImplementedBy<DefaultModuleFinder>().LifestyleTransient(),                Component.For<IAbpModuleManager>().ImplementedBy<AbpModuleManager>().LifestyleSingleton(),                Component.For<ILocalizationManager, LocalizationManager>().ImplementedBy<LocalizationManager>().LifestyleSingleton()

上面注冊的大部分都是配置類,最后四個有TypeFinder,ModuleFinder,ModuleManager, LocalizationManager.

Navigation: 導航相關,不曉得干啥

LocalizationConfiguration, LocalizationManager, 多語言相關,這個基本根據實際情況看。

Authorization: 授權相關, 跟Authentication有區別,前者授權,后者負責的呢登錄認證

Feature: 不曉得干啥

Settings: 看起來是設置相關的

ModuleConfiguration:  Abp模塊配置,這個看起來應該很重要,畢竟是搞Module么,這個可是Abp的核心概念

EventBus: 事件總線,看程序規模跟復雜度了,不過是很好玩的概念

MultiTenancy: 多租戶概念,也看業務邏輯跟系統應用場景了.

Caching: 緩存,必須得搞清楚的概念

Auditing: 審計,這個設計的還是不錯,有很好的參考價值, 但是也有一些弊端,需要綜合考慮,感覺利大于弊。

AbpStartup: 管Abp啟動階段的事,上述列的里面,這個是最先用到的,也是最先不用管的:)

TypeFinder: 類型查找的,

ModuleFinder, ModuleManager: 跟上面的ModuleConfiguration一樣,都是Module管理相關的

b.2 IocManager.Resolve<AbpStartupConfiguration>().Initialize();
Localization = IocManager.Resolve<ILocalizationConfiguration>();Modules = IocManager.Resolve<IModuleConfigurations>();Features = IocManager.Resolve<IFeatureConfiguration>();Navigation = IocManager.Resolve<INavigationConfiguration>();Authorization = IocManager.Resolve<IAuthorizationConfiguration>();Settings = IocManager.Resolve<ISettingsConfiguration>();UnitOfWork = IocManager.Resolve<IUnitOfWorkDefaultOptions>();EventBus = IocManager.Resolve<IEventBusConfiguration>();MultiTenancy = IocManager.Resolve<IMultiTenancyConfig>();Auditing = IocManager.Resolve<IAuditingConfiguration>();Caching = IocManager.Resolve<ICachingConfiguration>();

一共11項Configuration, 只是在b.2的介紹里面增加了UnitOfWork的Configuration

UnitOfWork: 工作單元, 這個概念現在很普遍,大家都應該了解.

b.3 _moduleManager.InitializeModules();
public virtual void InitializeModules(){    LoadAll();    var sortedModules = _modules.GetSortedModuleListByDependency();    sortedModules.ForEach(module => module.Instance.PReInitialize());    sortedModules.ForEach(module => module.Instance.Initialize());    sortedModules.ForEach(module => module.Instance.PostInitialize());}

1. 加載所有Module

2. 按照DepondsOnAttribute對各個Module排序

3. 一次按照PreInit, Init,PostInit的順序一次執行.

 

Application_End(object sender, EventArgs e)方法

Module Shutdown

var sortedModules = _modules.GetSortedModuleListByDependency();sortedModules.Reverse();sortedModules.ForEach(sm => sm.Instance.Shutdown());

這部分很簡單,就是通過各個Module的Shutdown釋放各個Module的資源


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 徐闻县| 嘉定区| 兴宁市| 灌南县| 丽水市| 彩票| 仁怀市| 卫辉市| 关岭| 泰安市| 灵山县| 油尖旺区| 辽阳市| 合肥市| 定襄县| 绥化市| 响水县| 正宁县| 江安县| 前郭尔| 万山特区| 连云港市| 北京市| 乌拉特中旗| 五大连池市| 门头沟区| 勃利县| 江阴市| 宁津县| 武陟县| 获嘉县| 寿阳县| 稷山县| 报价| 夏邑县| 溧阳市| 天等县| 乐亭县| 营口市| 翼城县| 全椒县|