VOOZH about

URL: https://www.nuget.org/packages/SyZero/

⇱ NuGet Gallery | SyZero 1.1.9




👁 Image
SyZero 1.1.9

dotnet add package SyZero --version 1.1.9
 
 
NuGet\Install-Package SyZero -Version 1.1.9
 
 
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" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SyZero" Version="1.1.9" />
 
Directory.Packages.props
<PackageReference Include="SyZero" />
 
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 SyZero --version 1.1.9
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SyZero, 1.1.9"
 
 
#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
 
 
#: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
 
Install as a Cake Addin
#tool nuget:?package=SyZero&version=1.1.9
 
Install as a Cake Tool
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 的约定注册
  • 🧩 应用基础设施 - SyZeroServiceBaseApplicationService、会话与权限基础能力
  • 💾 仓储与工作单元接口 - 统一抽象,方便接入 EF Core、SqlSugar、MongoDB
  • 🌐 轻量级服务管理 - 内置 LocalServiceManagementDBServiceManagement
  • 📣 轻量级事件总线 - 内置 LocalEventBusDBEventBus
  • 🔧 配置与工具 - 统一配置读取、异常模型、常用扩展工具

🚀 快速开始

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
 });
 }
}

⚠️ 说明

  1. builder.AddSyZero() 会注册核心依赖,并在 app.UseSyZero() 时初始化全局运行时。
  2. ISySession 是请求作用域对象,应只在请求链路内访问。
  3. 轻量级事件总线和服务管理适合简单场景;需要更强可靠性时,建议使用 SyZero.RabbitMQSyZero.RedisSyZero.ConsulSyZero.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 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
Loading failed