Medius 1.1.3
dotnet add package Medius --version 1.1.3
NuGet\Install-Package Medius -Version 1.1.3
<PackageReference Include="Medius" Version="1.1.3" />
<PackageVersion Include="Medius" Version="1.1.3" />
<PackageReference Include="Medius" />
paket add Medius --version 1.1.3
#r "nuget: Medius, 1.1.3"
#:package Medius@1.1.3
#addin nuget:?package=Medius&version=1.1.3
#tool nuget:?package=Medius&version=1.1.3
Medius
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 | Versions 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. |
-
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.