KazioR 1.0.0
dotnet add package KazioR --version 1.0.0
NuGet\Install-Package KazioR -Version 1.0.0
<PackageReference Include="KazioR" Version="1.0.0" />
<PackageVersion Include="KazioR" Version="1.0.0" />
<PackageReference Include="KazioR" />
paket add KazioR --version 1.0.0
#r "nuget: KazioR, 1.0.0"
#:package KazioR@1.0.0
#addin nuget:?package=KazioR&version=1.0.0
#tool nuget:?package=KazioR&version=1.0.0
KazioR
KazioR is a lightweight, in-process messaging library for .NET, implementing the Mediator pattern. It serves as a simplified clone of MediatR, designed to decouple application code by separating request senders from request handlers.
This repository includes the core library, a suite of unit tests, and a sample ASP.NET Core application demonstrating its usage.
📂 Project Structure
The repository is organized into the following solutions:
KazioR: The core library containing the interfaces (IKazioR,IRequest,IRequestHandler), the implementation, and Dependency Injection extensions.KazioR.Tests: XUnit tests covering command dispatching, generic/non-generic requests, and pipeline behaviors.KazioR.ExampleApp: A functional ASP.NET Core Web API that demonstrates how to configure and use KazioR in a real-world scenario.
🚀 Features
- In-Process Messaging: Decouple commands/queries from their execution logic.
- Automatic Registration: Scans assemblies to automatically register all requests and handlers.
- Pipeline Behaviors: Support for cross-cutting concerns (logging, validation, mutation) that run before the handler.
- Generic Support: Full support for both
IRequest(void) andIRequest<T>(return value). - Async/Await: Built from the ground up with
TaskandCancellationTokensupport.
🛠️ Installation
Currently, KazioR is designed to be referenced as a project dependency or a local NuGet package.
To add it to your project, reference the KazioR project in your solution.
📖 Usage
1. Define a Request
Create a class or record that implements IRequest (if no return value is needed) or IRequest<TResponse>.
using KazioR;
// A command that returns a string
public class HelloCommand : IRequest<string>
{
public string Name { get; set; } = string.Empty;
}
// A fire-and-forget command
public class LogSomethingCommand : IRequest
{
public string Message { get; set; } = string.Empty;
}
2. Create a Handler
Implement IRequestHandler<TRequest> or IRequestHandler<TRequest, TResponse>.
using KazioR;
public class HelloHandler : IRequestHandler<HelloCommand, string>
{
public Task<string> Handle(HelloCommand request, CancellationToken cancellationToken)
{
return Task.FromResult($"Hello, {request.Name}!");
}
}
3. Register Services (Dependency Injection)
In your Program.cs (or Startup.cs), use the AddKazioR extension method. This will scan the specified assembly for all requests and handlers.
var builder = WebApplication.CreateBuilder(args);
// Option 1: Scan the assembly where 'Program' is located
builder.Services.AddKazioR<Program>();
// Option 2: Scan the assembly containing a specific command
// builder.Services.AddKazioR(typeof(HelloCommand));
var app = builder.Build();
4. Send a Request
Inject IKazioR into your Controller or Service and send the request.
[ApiController]
[Route("[controller]")]
public class ExampleController(IKazioR kazior) : ControllerBase
{
[HttpGet]
public async Task<IActionResult> Get()
{
var result = await kazior.Send(new HelloCommand { Name = "World" });
return Ok(result);
}
}
🔗 Pipelines (Behaviors)
KazioR supports pipelines that allow you to execute logic before the handler is invoked. This is useful for logging, validation, or modifying request data.
Note: KazioR pipelines run sequentially. All registered behaviors' Run methods are executed before the final Handler.
Defining a Pipeline
Implement IPipelineBehaviour:
public class LoggingPipeline : IPipelineBehaviour
{
private readonly ILogger<LoggingPipeline> _logger;
public LoggingPipeline(ILogger<LoggingPipeline> logger)
{
_logger = logger;
}
public void Run(IRequest request, CancellationToken cancellationToken = default)
{
_logger.LogInformation("Processing request: {RequestName}", request.GetType().Name);
}
}
Registering a Pipeline
Pipelines must be explicitly added to the service collection:
builder.Services.AddKazioR<Program>();
// Register behaviors
builder.Services.AddKazioRBehaviour<LoggingPipeline>();
| Product | Versions 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. |
-
net10.0
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.0.0 | 143 | 1/25/2026 |