doc:添加cicd文档模块
This commit is contained in:
64
Yi.Doc.Md/02.框架功能模块教程/01.模块化.md
Normal file
64
Yi.Doc.Md/02.框架功能模块教程/01.模块化.md
Normal file
@@ -0,0 +1,64 @@
|
||||
## 简介
|
||||
通常,在Asp.NetCore中,**容器组装**过程 与 **管道模型组装** 过程 会将启动类文件变的非常长,同时也需要明确各个模块的依赖关系
|
||||
例如:
|
||||
我们需要仓储的功能,但是仓储的实现需要依赖Sqlsugar
|
||||
老的引入写法:
|
||||
``` cs
|
||||
service.AddUow();
|
||||
service.AddSqlsugar();
|
||||
......
|
||||
var app=service.Build();
|
||||
app.UseSqlsugar();
|
||||
......
|
||||
```
|
||||
这个文件会变得非常长,同时如果有顺序依赖关系的模块,还需按顺序组装
|
||||
例如:
|
||||
在Asp.NetCore,我们只有先鉴权才能进行授权操作
|
||||
当模块越来越多,我们维护起来将越来越困难,所以引入了模块化功能
|
||||
|
||||
## 使用
|
||||
每一个类库都可以有自己的模块化文件,我们通常命名为类库全名+Module
|
||||
例如:`Yi.Template.Application`的模块类叫做`YiTemplateApplicationModule`
|
||||
|
||||
另外,该模块类实现`AbpModule`基类
|
||||
ConfigureServices:用来配置容器服务
|
||||
OnApplicationInitialization:管道模型组装后执行
|
||||
|
||||
Abp内置`DependsOn`特性标签,可进行维护各个模块之间的依赖关系
|
||||
|
||||
## 完整例子
|
||||
创建模块化文件:
|
||||
``` cs
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.Domain;
|
||||
using Volo.Abp.Modularity;
|
||||
using Yi.Abp.Domain.Shared;
|
||||
using Yi.Framework.Bbs.Domain;
|
||||
using Yi.Framework.Mapster;
|
||||
using Yi.Framework.Rbac.Domain;
|
||||
|
||||
namespace Yi.Abp.Domain
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(YiAbpDomainSharedModule),
|
||||
|
||||
|
||||
typeof(YiFrameworkRbacDomainModule),
|
||||
typeof(YiFrameworkBbsDomainModule),
|
||||
|
||||
typeof(YiFrameworkMapsterModule),
|
||||
typeof(AbpDddDomainModule),
|
||||
typeof(AbpCachingModule)
|
||||
)]
|
||||
public class YiAbpDomainModule : AbpModule
|
||||
{
|
||||
public virtual void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnPreApplicationInitialization(ApplicationInitializationContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user