NexMediator.Core
1.0.1
Error package
dotnet add package NexMediator.Core --version 1.0.1
NuGet\Install-Package NexMediator.Core -Version 1.0.1
<PackageReference Include="NexMediator.Core" Version="1.0.1" />
<PackageVersion Include="NexMediator.Core" Version="1.0.1" />
<PackageReference Include="NexMediator.Core" />
paket add NexMediator.Core --version 1.0.1
#r "nuget: NexMediator.Core, 1.0.1"
#:package NexMediator.Core@1.0.1
#addin nuget:?package=NexMediator.Core&version=1.0.1
#tool nuget:?package=NexMediator.Core&version=1.0.1
NexMediator
π· NexMediator is a modern, extensible, and high-performance .NET library implementing the Mediator design pattern. It provides a robust alternative to MediatR for CQRS-based architectures β with powerful support for request/response, notifications, and streaming, all underpinned by a fully pluggable pipeline.
NuGet: NexMediator.Core
Install via VSCode:
dotnet add package NexMediator.Core
Install via Visual Studio:
Install-Package NexMediator.Core -Version 1.0.0
π Table of Contents
- β¨ About NexMediator
- π‘ Name Inspiration
- π Features
- π§± Core Concepts
- βοΈ Pipeline Behaviors
- π Setup & Configuration
- π¦ Example Usage
- π Docs
- π€ Contributing
- π License
β¨ About NexMediator
NexMediator is a clean, high-performance mediator engine for .NET, offering advanced capabilities like:
- π Asynchronous request/response handling
- π£ Parallel notification broadcasting
- π‘ Real-time streaming support
- π§© Configurable pipeline behaviors (logging, validation, caching, transactions)
- β‘ Optimized performance via compiled delegates (no reflection at runtime)
- π Full support for dependency injection and scoped lifetimes
- π§ͺ Designed for testability and modularization
Inspired by the CQRS pattern, it enables clean separation between commands, queries, and side effects β without adding runtime overhead.
π‘ Name Inspiration
NexMediator is short, modern, and meaningful:
π· Nex
- Next β The evolution of MediatR.
- Nexus β A central connection point β perfect for a mediator.
- Nex β Clean, minimal, trendy.
πΆ Mediator
- Instantly recognizable to .NET devs.
- Communicates its core role in CQRS and request orchestration.
Together: NexMediator β a clean and powerful orchestration layer for modern .NET apps.
π Features
- β Request / Command / Query handling with pipeline support
- π£ Publish notifications to multiple handlers in parallel
- π‘ Stream large datasets with support for async enumerables
- π§± Customizable pipeline for validation, logging, caching, and transactions
- π§ Delegate caching using Expression Trees
- π Full support for dependency injection and scoped lifetimes
- π§ͺ Designed for testability and modularization
π§± Core Concepts
| Component | Description |
|---|---|
INexRequest<TResponse> |
Base for commands & queries (immutable, typed) |
INexCommand<TResponse> |
Requests that modify state |
INexQuery<TResponse> |
Requests that fetch data without side-effects |
INexNotification |
Event-style messages β broadcast to many handlers |
INexRequestHandler<T,R> |
Business logic for requests |
INexNotificationHandler<T> |
Handle domain or system-wide notifications |
INexStreamRequest<T> |
Request type that supports IAsyncEnumerable<T> streaming |
INexPipelineBehavior<T,R> |
Middleware for cross-cutting concerns |
βοΈ Pipeline Behaviors
Built-in behaviors:
- πͺ΅ LoggingBehavior β Logs execution time, errors, and correlation ID
- π FluentValidationBehavior β Validates requests before they reach handlers
- π§ CachingBehavior β Adds response-level caching (with invalidation support)
- π§Ύ TransactionBehavior β Wraps command handlers in transaction scopes
π§© You can also define your own by implementing:
INexPipelineBehavior<TRequest, TResponse>
π Setup & Configuration
// In Startup.cs or Program.cs
//Nexmediator handlers
services.AddNexMediator();
Or
//NexMediator with Behaviors
services.AddNexMediator(options =>
{
options.AddBehavior(typeof(LoggingBehavior<,>), order: 1);
options.AddBehavior(typeof(FluentValidationBehavior<,>), order: 2);
options.AddBehavior(typeof(CachingBehavior<,>), order: 3);
options.AddBehavior(typeof(TransactionBehavior<,>), order: 4);
});
β¨ Supports automatic scanning of handlers and validators using Scrutor.
π¦ Example Usage
Command
public class CreateOrder : INexCommand<OrderResult> { ... }
public class CreateOrderHandler : INexRequestHandler<CreateOrder, OrderResult>
{
public async Task<OrderResult> Handle(CreateOrder request, CancellationToken ct)
{
// Business logic here
}
}
Notification
public class OrderCreated : INexNotification { ... }
public class AuditLogHandler : INexNotificationHandler<OrderCreated> { ... }
public class EmailNotifier : INexNotificationHandler<OrderCreated> { ... }
Stream Request
public class FetchEvents : INexStreamRequest<EventData> { ... }
public class FetchEventsHandler : INexStreamRequestHandler<FetchEvents, EventData>
{
public async IAsyncEnumerable<EventData> Handle(FetchEvents request, ...)
{
// yield return each event
}
}
π Docs
NexMediator is modularized in the following packages:
| Package | Description |
|---|---|
NexMediator.Core |
Main mediator engine |
NexMediator.Abstractions |
Contracts for requests, handlers, etc. |
NexMediator.Extensions |
DI helpers for registration |
NexMediator.Pipeline.Behaviors |
Built-in middleware (logging, cachingβ¦) |
π Full documentation is available in the /docs folder or project wiki (coming soon).
π€ Contributing
We welcome contributions!
- Open an issue or suggestion
- Fork and create a
feature/<your-feature>branch - Use Conventional Commits
- Submit a PR to
develop
π Branch strategy:
mainβ stable releasesdevelopβ integrates all new featuresfeature/*β work in progress branches
π License
NexMediator is Apache 2.0 Licensed β free for commercial and personal use.
Β© 2024β2025 Vagner Mello | (GitHub Profile) | (LinkeIn Profile) | Crafted with β€ in C#.
π· Tags
.NET β’ C# β’ CQRS β’ Mediator β’ Open Source β’ Apache-2.0 β’ NuGet β’ Clean Architecture β’ Pipeline β’ Notifications β’ Request Handling β’ Streaming β’ FluentValidation β’ Transaction β’ Expression Trees β’ Chain of Responsibility β’ Middleware β’ Microservices β’ DDD
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.4)
- NexMediator.Abstractions (>= 1.0.1)
- NexMediator.Pipeline (>= 1.0.1)
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 |
|---|