NexMediator.Core 1.0.1

Suggested Alternatives

NexMediator

Additional Details

Error package

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package NexMediator.Core --version 1.0.1
                    
NuGet\Install-Package NexMediator.Core -Version 1.0.1
                    
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="NexMediator.Core" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NexMediator.Core" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="NexMediator.Core" />
                    
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 NexMediator.Core --version 1.0.1
                    
#r "nuget: NexMediator.Core, 1.0.1"
                    
#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 NexMediator.Core@1.0.1
                    
#: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=NexMediator.Core&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=NexMediator.Core&version=1.0.1
                    
Install as a Cake Tool

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.

License .NET CSharp Pattern: Mediator Pattern: CQRS Target: Microservices Architecture: Clean Architecture: DDD Tested with: TDD

NuGet

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

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 releases
  • develop – integrates all new features
  • feature/* – 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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