Abp vNext 模块化系统简单介绍

怎么使用模块
1. 建立模块直接的依赖关系,可以通过DependsOnAttribute特性来确定依赖关系
2. 先配置模块,实现为模块填充数据和功能设置。
3. 使用模块提供的功能接口

怎么定义模块
1. 每个模块都应该定义一个模块类并继承AbpModule抽象了类
2. 通过DependsOnAttribute特性来关联需要使用的模块
3. 重写OnApplicationInitialization方法来初始化模块。也可以配置AspNetCore处理管道
4. 重写ConfigureServices

模块怎么加载
Abp系统在启动的时候才会通过反射扫描所有模块,每个模块可以通过DependsOnAttrbute特性来确定依赖关系。
ConfigureServices:是将你的服务添加到依赖注入系统并配置其他模块的主要方法
OnApplicationInitialization:初始化配置的所有模块的所有服务
OnApplicationShutdown:如果要在应用程序关闭时执行

Program.Main
|
Startup.ConfigureServices -> PreConfigureServices -> ConfigureServices -> PostConfigureServices -> OnPreApplicationInitialization -> OnApplicationInitialization -> OnPostApplicationInitialization
|
Application Shutdown

 目录结构

1. Application 为应用服务层,在这里编写服务的接口以及对应的实现
2. HttpApi.Hosting 相当于一个web项目,但这个主要依赖于HttpApi模块
3. HttpApi 职责主要是编写Controller,所有Api都写在这里,同时依赖于Application模块
4. Caching 缓存层
5. Application.Contracts 可以存放我们的传输对象(DTO),引用Domain.Shared
6. Domain 实体领域模型
7. Domain.Shared 层相当于Domain的一个扩展
8. EntityFrameworkCore自定义存储
9. ToolKits 扩展方法,公共工具类

原文地址:https://www.cnblogs.com/Cxiaoao/p/14857436.html