Medius 1.1.3

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

Logo Medius

NuGet version (Medius)
Build


Overview

Medius is a lightweight operation dispatcher for .NET.
It follows an ACQRS (Actions–Commands–Queries–Responsibility Segregation) model, providing a simple, type-safe way to execute operations through dedicated handlers.

Supports:

  • Commands, Queries, and Actions
  • Scoped lifetime handling
  • Simple dependency injection setup

Quick Start

// Register Medius
services.AddMedius();

// Define an operation
public sealed class GetTimeQuery : IMediusQuery<DateTime> { }

// Create its handler
public sealed class GetTimeHandler : MediusQueryHandler<GetTimeQuery, DateTime>
{
    public override Task<DateTime?> HandleQueryAsync(GetTimeQuery query, CancellationToken ct)
        => Task.FromResult<DateTime?>(DateTime.UtcNow);
}

// Invoke the operation
var result = await medius.InvokeAsync(new GetTimeQuery());

Concepts

ACQRS stands for Actions, Commands, and Queries with Responsibility Segregation.
It extends traditional CQRS principles by explicitly defining “Actions” as first-class operations that modify state and return results — providing a balanced approach between commands and queries.

Operation Type Base Interface Purpose Typical Return Type Example Handler
Command IMediusCommand Performs an action or side effect; does not return a result. MediusUndefinedType MediusCommandHandler<TCommand>
Query IMediusQuery<TQueryResult> Retrieves or computes data without modifying state. TQueryResult MediusQueryHandler<TQuery, TQueryResult>
Action IMediusAction<TActionResult> Performs an operation and returns a result (e.g., create, update, or process something). TActionResult MediusActionHandler<TAction, TActionResult>

Each operation has a matching handler that defines its execution logic.
All handlers are automatically discovered and registered by Medius during startup.


💡 Highlights

  • Zero configuration — handlers are auto-discovered via reflection
  • DI-friendly (handlers can depend on scoped or transient services)
  • No runtime reflection overhead after startup
  • Fully documented API with XML summaries

Project Goals

  • Lightweight by design — focuses on operation dispatching without external dependencies or pipelines.
  • Framework-agnostic — integrates cleanly into any .NET project using standard dependency injection.
  • Explicit, not opinionated — encourages simple, typed operations over hidden behaviors or conventions.
  • Built around ACQRS — unifies Actions, Commands, and Queries into a clear, consistent execution model.
  • Not a MediatR clone — built independently to provide a smaller, faster, and clearer alternative for internal dispatching needs.

Comparison Note

Medius and MediatR share the broad idea of dispatching operations,
but they differ fundamentally in purpose and design philosophy.

Medius

  • Self-contained — no external dependencies
  • Automatically discovers and registers handlers
  • Explicitly manages dependency-injection scopes
  • No pipeline or decorator infrastructure
  • ~300–400 lines of code — simple, lean, and transparent

MediatR

  • Includes a full behavioral pipeline with pre/post processors
  • Requires explicit registration for notifications
  • Introduces its own abstraction layers and decorators
  • Focuses on extensibility and pattern orchestration

Medius is not a MediatR clone.
It was built independently as a smaller, faster, and clearer alternative
for projects that only need clean operation dispatching,
not full mediator-pattern orchestration.


Requirements

  • .NET 8.0 or later

© 2025 ceronus — MIT License

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

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.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.1.3 208 10/13/2025
1.1.2 197 10/13/2025
1.1.0 281 2/11/2025
1.0.5 324 12/28/2023
1.0.4 474 12/28/2021
1.0.3 387 12/28/2021
1.0.2 380 12/28/2021
1.0.1 391 12/28/2021
1.0.0 570 12/28/2021