SyZero 1.1.9-dev.2
This is a prerelease version of SyZero.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SyZero --version 1.1.9-dev.2
NuGet\Install-Package SyZero -Version 1.1.9-dev.2
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="SyZero" Version="1.1.9-dev.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SyZero" Version="1.1.9-dev.2" />
<PackageReference Include="SyZero" />
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 SyZero --version 1.1.9-dev.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SyZero, 1.1.9-dev.2"
#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 SyZero@1.1.9-dev.2
#: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=SyZero&version=1.1.9-dev.2&prerelease
#tool nuget:?package=SyZero&version=1.1.9-dev.2&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SyZero
SyZero 是一个轻量级的 .NET 微服务框架核心库,提供依赖注入、基础领域模型、服务管理和轻量级事件总线等通用能力。
📦 安装
dotnet add package SyZero
✨ 特性
- 🚀 依赖注入 - 基于
Microsoft.Extensions.DependencyInjection的约定注册 - 🧩 应用基础设施 -
SyZeroServiceBase、ApplicationService、会话与权限基础能力 - 💾 仓储与工作单元接口 - 统一抽象,方便接入 EF Core、SqlSugar、MongoDB
- 🌐 轻量级服务管理 - 内置
LocalServiceManagement、DBServiceManagement - 📣 轻量级事件总线 - 内置
LocalEventBus、DBEventBus - 🔧 配置与工具 - 统一配置读取、异常模型、常用扩展工具
🚀 快速开始
1. 注册核心服务
using SyZero;
var builder = WebApplication.CreateBuilder(args);
builder.AddSyZero();
builder.Services.AddControllers();
var app = builder.Build();
app.UseSyZero();
app.MapControllers();
app.Run();
2. 使用约定注入
using SyZero.Dependency;
public interface IUserService
{
Task<string> GetNameAsync(long id);
}
public class UserService : IUserService, IScopedDependency
{
public Task<string> GetNameAsync(long id)
{
return Task.FromResult($"user-{id}");
}
}
3. 继承应用服务基类
using SyZero.Application.Service;
public class UserAppService : ApplicationService
{
public string GetCurrentUser()
{
return SySession.UserName ?? "anonymous";
}
}
📖 轻量级服务管理
SyZero 核心包内置两种无需额外中间件的服务管理实现:
| 实现 | 场景 | 特点 |
|---|---|---|
LocalServiceManagement |
单机 / 开发环境 | 基于本地文件,无外部依赖 |
DBServiceManagement |
简单多实例部署 | 基于数据库,支持健康检查和 Leader 选举 |
示例:
builder.Services.AddLocalServiceManagement(options =>
{
options.EnableHealthCheck = true;
options.EnableLeaderElection = false;
});
📖 轻量级事件总线
SyZero 核心包内置两种事件总线实现:
| 实现 | 场景 | 特点 |
|---|---|---|
LocalEventBus |
进程内事件 | 基于内存,适合单体应用 |
DBEventBus |
需要持久化与重试 | 基于数据库,适合简单分布式场景 |
示例:
using SyZero.EventBus;
builder.Services.AddLocalEventBus();
public class OrderCreatedEvent : EventBase
{
public long OrderId { get; set; }
}
public class OrderCreatedHandler : IEventHandler<OrderCreatedEvent>
{
public Task HandleAsync(OrderCreatedEvent @event)
{
Console.WriteLine($"order created: {@event.OrderId}");
return Task.CompletedTask;
}
}
发布事件:
public class OrderService
{
private readonly IEventBus _eventBus;
public OrderService(IEventBus eventBus)
{
_eventBus = eventBus;
_eventBus.Subscribe<OrderCreatedEvent, OrderCreatedHandler>(() => new OrderCreatedHandler());
}
public Task CreateAsync(long orderId)
{
return _eventBus.PublishAsync(new OrderCreatedEvent
{
OrderId = orderId
});
}
}
⚠️ 说明
builder.AddSyZero()会注册核心依赖,并在app.UseSyZero()时初始化全局运行时。ISySession是请求作用域对象,应只在请求链路内访问。- 轻量级事件总线和服务管理适合简单场景;需要更强可靠性时,建议使用
SyZero.RabbitMQ、SyZero.Redis、SyZero.Consul、SyZero.Nacos等模块。
📄 许可证
MIT License - 详见 LICENSE
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Castle.Core (>= 5.1.1)
- Dynamitey (>= 2.0.10.189)
- ImpromptuInterface (>= 7.0.1)
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.6)
- Microsoft.Extensions.Configuration (>= 9.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.0)
- Microsoft.Extensions.Configuration.Json (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.0)
- Microsoft.Extensions.DependencyModel (>= 9.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- Refit (>= 8.0.0)
- Snowflake.Core (>= 2.0.0)
- System.Linq.Dynamic.Core (>= 1.6.6)
NuGet packages (16)
Showing the top 5 NuGet packages that depend on SyZero:
| Package | Downloads |
|---|---|
|
SyZero.Web.Common
SyZero-Web-Common |
|
|
SyZero.EntityFrameworkCore
SyZero-EntityFrameworkCore |
|
|
SyZero.Log4Net
SyZero-Log4Net |
|
|
SyZero.AutoMapper
SyZero AutoMapper integration - Object-to-object mapping with automatic profile scanning |
|
|
SyZero.Redis
SyZero-Redis |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.9 | 473 | 4/19/2026 |
| 1.1.9-dev.2 | 62 | 4/19/2026 |
| 1.1.9-dev.1 | 68 | 4/17/2026 |
| 1.1.8 | 476 | 4/17/2026 |
| 1.1.6 | 471 | 4/17/2026 |
| 1.1.6-dev.1 | 52 | 4/17/2026 |
| 1.1.5 | 515 | 4/13/2026 |
| 1.1.5-dev.3 | 79 | 4/13/2026 |
| 1.1.5-dev.2 | 97 | 2/11/2026 |
| 1.1.5-dev.1 | 89 | 1/29/2026 |
| 1.1.4 | 568 | 1/2/2026 |
| 1.1.4-dev.2 | 80 | 1/2/2026 |
| 1.1.4-dev.1 | 80 | 12/30/2025 |
| 1.1.3 | 565 | 12/30/2025 |
| 1.1.3-dev.6 | 93 | 12/30/2025 |
| 1.1.3-dev.3 | 137 | 1/19/2024 |
| 1.1.3-dev.2 | 200 | 11/3/2023 |
| 1.1.3-dev.1 | 226 | 3/21/2023 |
| 1.1.2 | 2,088 | 3/15/2023 |
| 1.1.2-dev.108.29344 | 203 | 3/15/2023 |
Loading failed