-
Notifications
You must be signed in to change notification settings - Fork 767
Closed
Labels
Milestone
Description
您的功能请求与现有问题有关吗?请描述
上次 #139 更新之后,一直有反馈说Pack手动加载反傻瓜化,希望恢复自动加载Pack的功能,因此添加此新特性。
在IOsharpBuilder
接口中新增了功能AddPacks(params Type[] exceptPackTypes);
,使用演示:
手动加载方案:
public void ConfigureServices(IServiceCollection services)
{
services.AddOSharp()
.AddPack<Log4NetPack>()
.AddPack<AutoMapperPack>()
.AddPack<EndpointsPack>()
.AddPack<SwaggerPack>()
.AddPack<AuthenticationPack>()
.AddPack<FunctionAuthorizationPack>()
.AddPack<DataAuthorizationPack>()
.AddPack<SqlServerDefaultDbContextMigrationPack>()
.AddPack<AuditPack>()
.AddPack<SwaggerPack>();
}
更新后,可实现自动加载方案:
不需要HangfirePack,可排除之
public void ConfigureServices(IServiceCollection services)
{
services.AddOSharp().AddPacks(typeof(HangfirePack));
}
提示:
个人认为,系统加载哪些Pack不加载哪些Pack,应该做到心中有数,避免加载不需要使用到的Pack,手动加载还是有其必要性的。