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" />
<PackageReference Include="Zhytech.FactoryCenter" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Zhytech.FactoryCenter&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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.
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
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 |