![]() |
VOOZH | about |
dotnet add package SyZero --version 1.1.9
NuGet\Install-Package SyZero -Version 1.1.9
<PackageReference Include="SyZero" Version="1.1.9" />
<PackageVersion Include="SyZero" Version="1.1.9" />Directory.Packages.props
<PackageReference Include="SyZero" />Project file
paket add SyZero --version 1.1.9
#r "nuget: SyZero, 1.1.9"
#:package SyZero@1.1.9
#addin nuget:?package=SyZero&version=1.1.9Install as a Cake Addin
#tool nuget:?package=SyZero&version=1.1.9Install as a Cake Tool
SyZero 是一个轻量级的 .NET 微服务框架核心库,提供依赖注入、基础领域模型、服务管理和轻量级事件总线等通用能力。
dotnet add package SyZero
Microsoft.Extensions.DependencyInjection 的约定注册SyZeroServiceBase、ApplicationService、会话与权限基础能力LocalServiceManagement、DBServiceManagementLocalEventBus、DBEventBususing SyZero;
var builder = WebApplication.CreateBuilder(args);
builder.AddSyZero();
builder.Services.AddControllers();
var app = builder.Build();
app.UseSyZero();
app.MapControllers();
app.Run();
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}");
}
}
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 - 详见
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
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 |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.9 | 493 | 4/19/2026 |
| 1.1.9-dev.2 | 70 | 4/19/2026 |
| 1.1.9-dev.1 | 78 | 4/17/2026 |
| 1.1.8 | 486 | 4/17/2026 |
| 1.1.6 | 483 | 4/17/2026 |
| 1.1.6-dev.1 | 62 | 4/17/2026 |
| 1.1.5 | 527 | 4/13/2026 |
| 1.1.5-dev.3 | 90 | 4/13/2026 |
| 1.1.5-dev.2 | 108 | 2/11/2026 |
| 1.1.5-dev.1 | 101 | 1/29/2026 |
| 1.1.4 | 572 | 1/2/2026 |
| 1.1.4-dev.2 | 87 | 1/2/2026 |
| 1.1.4-dev.1 | 87 | 12/30/2025 |
| 1.1.3 | 570 | 12/30/2025 |
| 1.1.3-dev.6 | 97 | 12/30/2025 |
| 1.1.3-dev.3 | 142 | 1/19/2024 |
| 1.1.3-dev.2 | 204 | 11/3/2023 |
| 1.1.3-dev.1 | 230 | 3/21/2023 |
| 1.1.2 | 2,093 | 3/15/2023 |
| 1.1.2-dev.108.29344 | 207 | 3/15/2023 |