SuCaiFlow.Contracts
1.0.0
dotnet add package SuCaiFlow.Contracts --version 1.0.0
NuGet\Install-Package SuCaiFlow.Contracts -Version 1.0.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="SuCaiFlow.Contracts" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SuCaiFlow.Contracts" Version="1.0.0" />
<PackageReference Include="SuCaiFlow.Contracts" />
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 SuCaiFlow.Contracts --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SuCaiFlow.Contracts, 1.0.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 SuCaiFlow.Contracts@1.0.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=SuCaiFlow.Contracts&version=1.0.0
#tool nuget:?package=SuCaiFlow.Contracts&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SuCaiFlow
SuCaiFlow 是一个素材采集流程库,旨在提供一个灵活、可扩展的素材采集框架,可以轻松集成到任何.NET 应用程序中。
功能特性
- 模块化设计: 分为 Contracts、Core 和 EntityFramework 三个组件,便于独立使用
- EF Core 集成: 提供完整的 EF Core 支持,包括 PostgreSQL 等数据库
- 事件驱动: 内置事件发布机制,便于扩展和监控
- 多站点支持: 支持多种站点的采集器,可轻松扩展
- 任务管理: 完整的采集任务生命周期管理
- 并发控制: 支持并发采集任务执行
安装
<PackageReference Include="SuCaiFlow" Version="1.0.0" />
或者通过项目引用方式使用。
快速开始
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SuCaiFlow.Core.Extensions;
using SuCaiFlow.EntityFramework.Extensions;
var builder = Host.CreateApplicationBuilder(args);
// 添加 SuCaiFlow 服务
builder.Services.AddSuCaiFlow();
// 添加 SuCaiFlow 数据库上下文和仓储
builder.Services.AddSuCaiFlowDbContext<SuCaiFlowDbContext>(options =>
options.UseInMemoryDatabase("SuCaiFlowDemo"));
builder.Services.AddSuCaiFlowRepositories();
var host = builder.Build();
// 使用服务
var collectionTaskService = host.Services.GetRequiredService<ICollectionTaskService>();
// 创建采集任务
var taskId = await collectionTaskService.CreateCollectionTaskAsync(
"示例任务",
"这是一个示例采集任务",
"<https://example.com>",
".item",
new Dictionary<string, string> { { "key", "value" } });
// 启动任务
await collectionTaskService.StartCollectionTaskAsync(taskId);
核心组件
Contracts
包含所有实体和接口定义:
- 实体: CollectionTask, CollectedAsset, CollectionTaskConfig
- 接口: ICollectionTaskService, IAssetService, ISiteCollector 等
Core
包含业务逻辑实现:
- 服务: CollectionTaskService, AssetService, EventPublisher
- 基础类: BaseSiteCollector
- 扩展方法: SuCaiFlowExtensions
EntityFramework
包含数据访问实现:
- DbContext: SuCaiFlowDbContext
- 仓储: CollectionTaskRepository, AssetRepository
- EF Core 扩展方法
扩展功能
添加自定义站点采集器
public class CustomSiteCollector : BaseSiteCollector
{
public override string SiteIdentifier => "customsite.com";
public override string DisplayName => "自定义站点采集器";
public override async Task<List<string>> ParsePageAsync(CollectionTask task, string pageUrl, CollectionTaskConfig? config = null)
{
// 实现页面解析逻辑
return new List<string>();
}
public override async Task<CollectedAsset?> DownloadAssetAsync(string url, CollectionTaskConfig? config = null)
{
// 实现资源下载逻辑
return new CollectedAsset();
}
}
然后在服务注册中添加:
builder.Services.AddScoped<ISiteCollector, CustomSiteCollector>();
依赖注入扩展
SuCaiFlow 提供以下依赖注入扩展方法:
- AddSuCaiFlow(): 注册所有核心服务
- AddSuCaiFlowDbContext<T>(): 注册数据库上下文
- AddSuCaiFlowRepositories(): 注册仓储实现
许可证
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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.
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SuCaiFlow.Contracts:
| Package | Downloads |
|---|---|
|
SuCaiFlow.Core
A powerful asset collection framework for .NET applications. |
|
|
SuCaiFlow.EntityFramework
A powerful asset collection framework for .NET applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 108 | 1/1/2026 |