Orchestrix.Mediator.SourceGenerators
1.0.0
dotnet add package Orchestrix.Mediator.SourceGenerators --version 1.0.0
NuGet\Install-Package Orchestrix.Mediator.SourceGenerators -Version 1.0.0
<PackageReference Include="Orchestrix.Mediator.SourceGenerators" Version="1.0.0" />
<PackageVersion Include="Orchestrix.Mediator.SourceGenerators" Version="1.0.0" />
<PackageReference Include="Orchestrix.Mediator.SourceGenerators" />
paket add Orchestrix.Mediator.SourceGenerators --version 1.0.0
#r "nuget: Orchestrix.Mediator.SourceGenerators, 1.0.0"
#:package Orchestrix.Mediator.SourceGenerators@1.0.0
#addin nuget:?package=Orchestrix.Mediator.SourceGenerators&version=1.0.0
#tool nuget:?package=Orchestrix.Mediator.SourceGenerators&version=1.0.0
<p align="center"> <img src="logo.png" alt="Orchestrix.Mediator Logo" width="1024" /> </p>
๐ฆ Orchestrix.Mediator
Modern, extensible, and production-grade mediator engine for .NET 8+
With parallel notifications, streaming, pipelines, source generators, and full CQRS support via extensions.
โจ Why Orchestrix.Mediator?
Orchestrix.Mediator is a complete rethinking of a mediator engine for the modern .NET ecosystem.
โ
Reflection-based dispatch by default
๐งฌ Source generator dispatch (opt-in)
๐ข Sequential & parallel notifications
๐ก Streaming request handling (IAsyncEnumerable<T>
)
๐งฑ Fully pluggable via pipelines and diagnostics hooks
๐งฉ CQRS-style ICommand
, IQuery
, and handler support (extension)
๐ง Minimal API & Controller friendly
๐งช Built for performance and testability
Full Documentation: Orchestrix.Mediator Docs โ
๐ฆ Installation
dotnet add package Orchestrix.Mediator
Optional Extensions
# Optional: Source generator-based dispatch
dotnet add package Orchestrix.Mediator.SourceGenerators
# Optional: CQRS abstractions (ICommand, IQuery, etc.)
dotnet add package Orchestrix.Mediator.Cqrs
๐งฐ Basic Example โ Core Only
๐งพ Define a request, notification, and handlers:
public record TestCommand(string? Name, string? Surname, string? Email, string? Phone) : IRequest<string>;
public class TestCommandHandler(IPublisher publisher) : IRequestHandler<TestCommand, string>
{
public async ValueTask<string> Handle(TestCommand request, CancellationToken cancellationToken)
{
Console.WriteLine($"Hello {request.Name} {request.Surname} {request.Email} {request.Phone}");
await publisher.Publish(new TestNotification(request.Name), cancellationToken);
return "OK";
}
}
public record TestNotification(string? Name) : INotification;
public class LogTestNotificationHandler : INotificationHandler<TestNotification>
{
public ValueTask Handle(TestNotification notification, CancellationToken cancellationToken)
{
Console.WriteLine($"[Generic Handler] Logging TestNotification: {notification.Name}");
return default;
}
}
public class ParallelTestNotificationHandler : IParallelNotificationHandler<TestNotification>
{
public async ValueTask Handle(TestNotification notification, CancellationToken cancellationToken)
{
Console.WriteLine($"[Parallel Handler] Simulating async work for {notification.Name}");
await Task.Delay(300, cancellationToken);
}
}
โ๏ธ Minimal API / Controller Example
[HttpGet]
public async Task<IActionResult> Test([FromServices] ISender sender)
{
var command = new TestCommand("Mohammad", "Anzawi", "anzawi@test.com", "00000");
var result = await sender.Send(command, CancellationToken.None);
return Ok(result);
}
๐ง Configuration
Default (Reflection-based):
services.AddOrchestrix(cfg => cfg.RegisterHandlersFromAssemblies(typeof(SomeHandler).Assembly));
Enable Source Generator (opt-in):
services.AddOrchestrix(cfg =>
{
cfg.UseSourceGenerator() // add this line
.RegisterHandlersFromAssemblies(typeof(SomeHandler).Assembly);
});
๐งฌ Dispatch Modes
Mode | Description |
---|---|
๐ช Reflection | Resolves via IServiceProvider |
โก Source Generator | Compile-time dispatch, AOT safe |
Source generators eliminate runtime lookup and boost performance.
See Source Generators โ
โ Core Interfaces
Interface | Role |
---|---|
IRequest , IRequest<T> |
Request contracts |
INotification |
Fire-and-forget events |
ISender , IPublisher , IMediator |
Dispatch interfaces |
IRequestHandler<T> , IRequestHandler<T, R> |
Request handlers |
INotificationHandler<T> , IParallelNotificationHandler<T> |
Event handlers |
IStreamRequest<T> , IStreamRequestHandler<T, R> |
Async streaming support |
IPipelineBehavior<T, R> |
Pipeline behaviors |
VoidMarker (internal) |
Used internally to support IRequest (non-generic) in source-generated dispatch |
๐ง Diagnostics & Hooks
Interface | Role |
---|---|
ISendHook , IPublishHook , IStreamHook |
Lifecycle instrumentation |
IHookExecutor , HookConfiguration |
Hook orchestration & control |
Enable diagnostics, logging, tracing, or global behaviors with zero impact on business logic.
See Hooks & Pipelines โ
๐งญ CQRS Extension
Install:
dotnet add package Orchestrix.Mediator.Cqrs
Adds:
// Marker interfaces
ICommand, ICommand<TResponse>
IQuery<TResponse>
// Handlers
ICommandHandler<T>, ICommandHandler<T, R>
IQueryHandler<T, R>
Supports both:
public class SaveCommand : ICommand; // No return
public class SaveCommand : ICommand<Unit>; // Explicit unit
See CQRS Guide โ
๐ Documentation Index
Full Documentation: Orchestrix.Mediator Docs โ
Topic | Description |
---|---|
๐ Getting Started | Install, configure, send, publish |
๐ง Core Concepts | Interfaces, dispatcher roles |
๐งญ CQRS Guide | ICommand , IQuery , etc. |
โจ Source Generators | Compile-time dispatching |
๐ช Hooks & Pipelines | Diagnostics + middleware |
๐ก Streaming | Streaming requests |
๐ข Notifications | Publish, parallelism |
๐ Diagnostics | Tracing, hook config |
๐ Sagas Guide | Add in-process Sagas |
๐ง Advanced Usage | TrySend , TryPublish , fallback |
๐ API Reference | Interface + type index |
โ FAQ | Answers to common Qs |
๐ Migration Guide | From MediatR to Orchestrix |
๐ Migrating from MediatR?
See MIGRATION.md
- Swap
IMediator
toISender
andIPublisher
- Replace
IRequestHandler<>
withICommandHandler<>
/IQueryHandler<>
- Replace
INotificationHandler<>
withIParallelNotificationHandler<>
if parallel behavior is needed - Enable
MediatorMode.SourceGenerator
for performance - Use
Dispatch
,DispatchVoid
,TrySend
,TryPublish
, etc.
๐ Performance-Ready
โก Zero-reflection dispatch via source generators
๐งต True parallel notifications
โ
ValueTask
everywhere
๐งฌ NativeAOT-friendly
๐ง Small, fast, testable core
๐ License
MIT โ free for personal and commercial use.
๐ Acknowledgements
Inspired by MediatR
Rebuilt from scratch for modern .NET by @anzawi
Proudly open-source and forever free
๐ฆ Orchestrix.Mediator: Mediation, Modernized.
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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 280 | 7/20/2025 |