CodeWF.EventBus
轻量进程内事件总线
模块解耦的进程内事件总线:Command 命令分发、Query 查询回传(简易 CQRS),多 IOC 容器集成(MS.DI / AspNetCore / DryIoc / Prism / 任意容器),WPF、WinForms、Avalonia、ASP.NET Core、控制台通用,NativeAOT 友好——更轻的 MediatR 替代。
net8.0net10.0net11.0 事件总线CQRSMediatR 替代 开源免费
> dotnet add package CodeWF.EventBus
GitHub ↗ GitHub Star ★ 58
NuGet 下载 2.7w+
子包数量 4
为什么选它
Features⚡
Command + Query 命令分发与查询回传一套 API,进程内简易 CQRS。
🧩
多 IOC 集成 MS.DI / AspNetCore / DryIoc / Prism 开箱集成,另有容器无关抽象。
🖥️
UI 框架无关 WPF、WinForms、Avalonia、ASP.NET Core、控制台通用。
🚀
NativeAOT 友好 AvaAOT / ConsoleAOT 验证工程随仓库维护。
🪶
零依赖核心 核心包无第三方依赖,集成包按需引入。
🔗
可升级到 IPC 跨进程场景无缝升级 EventBus.Socket,API 风格一致。
EventBus
AspNetCore.EventBus
DryIoc.EventBus
IOC.EventBus
> dotnet add package CodeWF.EventBus
核心包按需引入;目标框架 net8.0 / net10.0 / net11.0。全部包在 nuget.org 与 GitHub 同步发布。
定义命令与查询
csharp
public abstract class Command
{
}
public abstract class Query<TResponse> : Command
{
public abstract TResponse Result { get; set; }
}
public sealed class CreateProductCommand : Command
{
public string Name { get; set; } = string.Empty;
public decimal Price { get; set; }
}
public sealed class ProductQuery : Query<ProductItemDto?>
{
public Guid ProductId { get; set; }
public override ProductItemDto? Result { get; set; }
} 包列表
Packages按需安装,版本与核心包保持同步发布
| 包名 | 说明 | |
|---|---|---|
| CodeWF.EventBus | 核心包 | |
| CodeWF.AspNetCore.EventBus | 集成 / 扩展包 | |
| CodeWF.DryIoc.EventBus | 集成 / 扩展包 | |
| CodeWF.IOC.EventBus | 集成 / 扩展包 |
3.4.5.26 fix: add a loaded-assembly fallback when the entry assembly is unavailable.
3.4.5.25 fix: validate IOC integration arguments and null service resolutions.
3.4.5.24 build: enable nullable reference types in the core package.
谁在使用
Used By码坊自家的应用都在用它,问题反馈与修复路径最短