Zhytech.FactoryCenter 1.2.0

dotnet add package Zhytech.FactoryCenter --version 1.2.0
                    
NuGet\Install-Package Zhytech.FactoryCenter -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zhytech.FactoryCenter" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zhytech.FactoryCenter" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Zhytech.FactoryCenter" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zhytech.FactoryCenter --version 1.2.0
                    
#r "nuget: Zhytech.FactoryCenter, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zhytech.FactoryCenter@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zhytech.FactoryCenter&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Zhytech.FactoryCenter&version=1.2.0
                    
Install as a Cake Tool

FactoryCenter

配置驱动 + 动态路由的通用工厂编排引擎(.NET 8.0 类库)。

特性

  • 配置驱动:业务(BizList)经路由(BizToFactory)编排多个工厂(FactoryList),由数据库配置驱动,无硬编码。
  • 动态路由:FactoryRegistry 按 FactoryCode 在运行时解析 IFactory 实现,业务工厂由引入方注册。
  • 顺序编排:FactoryOrchestrator 按 ExecuteOrder 执行工厂链,失败按 IsContinue 决定继续或中断。
  • 上下文共享:FactoryContext.ContextData 在工厂链中传递,上游输出经出参映射(FactoryOutputParam)后供下游工厂消费。
  • 可观测:每次调用经 FactoryInvokeLog 落库。

快速接入

FactoryCenter 拥有独立的 FactoryCenterDbContext,在 Startup/Program 中注入一次即可;可依据连接字符串与 EF Core 提供程序(SQL Server / MySQL / PostgreSQL / SQLite 等)指向任意数据库,与业务库解耦。

// 1. 在 Program/Startup 中注入一次(依据连接字符串选择数据库提供程序)
//    SQL Server
services.AddFactoryCenter(options =>
    options.UseSqlServer(Configuration.GetConnectionString("FactoryCenter")));

//    MySQL(宿主工程需引用 Pomelo.EntityFrameworkCore.MySql)
// services.AddFactoryCenter(options =>
//     options.UseMySql(connStr, ServerVersion.AutoDetect(connStr)));

//    PostgreSQL(宿主工程需引用 Npgsql.EntityFrameworkCore.PostgreSQL)
// services.AddFactoryCenter(options => options.UseNpgsql(connStr));

//    SQLite
// services.AddFactoryCenter(options => options.UseSqlite(connStr));

// 2. 注册业务工厂(IFactory 实现,由引入方提供)
services.AddScoped<IFactory, YourFactoryA>();

// 3. 调用
var results = await factoryCenterService.ExecuteAsync(bizCode, userInputs, currentUserID, hospitalID, ct);

说明:FactoryCenter 仅依赖 EF Core 关系型抽象,不绑定具体提供程序;切换数据库只需在 optionsAction 中改用对应 UseXxx 并确保宿主已安装该提供程序包。

数据表(Code First)

BizList / FactoryList / FactoryInputParam / BizToFactory / FactoryOutputParam / FactoryInvokeLog,由 FactoryCenterDbContext 承载,通过连接字符串指向的目标数据库建表。

详见项目内 FactoryCenter项目说明文档.md。

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 72 10/9/2026