Skip to content

添加自动加载所有Pack功能,简化系统初始化流程 #177

@gmf520

Description

@gmf520

您的功能请求与现有问题有关吗?请描述

上次 #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,手动加载还是有其必要性的。

关联Commit

c4cb86f

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions