ModulusKit.Mediator.Abstractions 1.1.0

dotnet add package ModulusKit.Mediator.Abstractions --version 1.1.0
                    
NuGet\Install-Package ModulusKit.Mediator.Abstractions -Version 1.1.0
                    
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="ModulusKit.Mediator.Abstractions" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ModulusKit.Mediator.Abstractions" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ModulusKit.Mediator.Abstractions" />
                    
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 ModulusKit.Mediator.Abstractions --version 1.1.0
                    
#r "nuget: ModulusKit.Mediator.Abstractions, 1.1.0"
                    
#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 ModulusKit.Mediator.Abstractions@1.1.0
                    
#: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=ModulusKit.Mediator.Abstractions&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ModulusKit.Mediator.Abstractions&version=1.1.0
                    
Install as a Cake Tool

Modulus.Mediator.Abstractions

Abstractions for the Modulus mediator — interfaces, Result types, and pipeline behavior contracts.

Installation

dotnet add package ModulusKit.Mediator.Abstractions

Key Types

Commands and Queries

// Command with no return value
public record CreateOrder(string CustomerId) : ICommand;

// Command with a return value
public record CreateProduct(string Name, decimal Price) : ICommand<Guid>;

// Query
public record GetOrderById(Guid Id) : IQuery<OrderDto>;

// Streaming query
public record GetOrderStream() : IStreamQuery<OrderDto>;

// Domain event
public record OrderCreated(Guid OrderId) : IDomainEvent;

Handlers

public class CreateOrderHandler : ICommandHandler<CreateOrder>
{
    public Task<Result> Handle(CreateOrder command, CancellationToken ct)
    {
        // ...
        return Task.FromResult(Result.Success());
    }
}

public class GetOrderByIdHandler : IQueryHandler<GetOrderById, OrderDto>
{
    public Task<Result<OrderDto>> Handle(GetOrderById query, CancellationToken ct)
    {
        // ...
        return Task.FromResult(Result<OrderDto>.Success(dto));
    }
}

Result Pattern

// Success
Result.Success();
Result<OrderDto>.Success(dto);

// Failure
Result.Failure(Error.NotFound("Order.NotFound", "Order was not found"));
Result<OrderDto>.Failure(Error.Validation("Order.InvalidId", "ID must not be empty"));

// Implicit conversions
Result result = Error.NotFound("Order.NotFound", "Not found");

// Checking results
if (result.IsSuccess) { /* ... */ }
if (result.IsFailure) { /* inspect result.Errors */ }

Error Types

Error.Failure(code, description)      // General failure
Error.Validation(code, description)   // Validation error
Error.NotFound(code, description)     // Resource not found
Error.Conflict(code, description)     // State conflict
Error.Unauthorized(code, description) // Authentication required
Error.Forbidden(code, description)    // Permission denied

Pipeline Behaviors

public class TimingBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
    where TRequest : notnull
{
    public async Task<TResponse> Handle(
        TRequest request,
        RequestHandlerDelegate<TResponse> next,
        CancellationToken cancellationToken)
    {
        var sw = Stopwatch.StartNew();
        var response = await next();
        sw.Stop();
        // log elapsed time
        return response;
    }
}

Source Generators & Analyzers

Referencing this package transitively includes the ModulusKit.Generators and ModulusKit.Analyzers packages as analyzer references. This means your project automatically gets:

  • Source generators for strongly typed IDs, handler registration, and module auto-discovery
  • Roslyn analyzers (MOD001--MOD005) for compile-time architecture enforcement

Strongly Typed IDs

Use the [StronglyTypedId] attribute to generate type-safe entity identifiers with full EF Core, JSON, and model binding support:

using Modulus.Mediator.Abstractions;

[StronglyTypedId]
public readonly partial record struct OrderId;

[StronglyTypedId(typeof(int))]
public readonly partial record struct SequenceNumber;

Supported backing types: Guid (default), int, long.

Module Ordering

Use the [ModuleOrder] attribute to control module initialization order in the auto-discovery generator:

[ModuleOrder(1)]
public class CatalogModule : IModuleRegistration { /* ... */ }

Learn More

See the Modulus repository for full documentation.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ModulusKit.Mediator.Abstractions:

Package Downloads
ModulusKit.Mediator

Lightweight CQRS mediator for .NET with pipeline behaviors, validation, logging, and a built-in Result pattern.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 30 3/5/2026
1.0.1 36 3/3/2026