Caravel.MediatR 0.21.0

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

Caravel.MediatR

This package contains reusable MediatR behaviours.

Logging Pipeline Behaviour

Creates an entry Log for the start and failure of each request in the pipeline. It will log the error in case the request fails.

builder.Services.AddMediatR(cfg =>
{
    cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
    cfg.AddOpenBehavior(typeof(LoggingPipelineBehaviour<,>));
});

Validation Pipeline Behaviour

Validates requests using FluentValidation. This behaviour detects via reflection if the Response is using the Result pattern to avoid throwing unnecessary ValidationException, if not then throws it.

builder.Services.AddMediatR(cfg =>
{
    cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
    cfg.AddOpenBehavior(typeof(ValidationPipelineBehaviour<,>));
});
{
  "code": "invalid_fields",
  "title": "Invalid Fields",
  "status": 400,
  "errors": {
    "field1": ["error_1", "error_2"]
  }
}

Idempotent Pipeline Behaviour

Ensures all requests implementing interface IIdempotentRequest are idempotent.

builder.Services.AddMediatR(cfg =>
{
    cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
    cfg.AddOpenBehavior(typeof(IdempotentPipelineBehaviour<,>));
});
{
  "code": "duplicate_request",
  "title": "Duplicate request",
  "status": 204,
  "detail": "Duplicate request with Idempotent Key 53655b3d-48d5-4ac1-ba73-4318b3b702e8."
}

Caching Pipeline Behaviour

Caches responses where the request implements ICachedQuery.

// Requires implementing the caching service.
builder.Services.AddSingleton<ICacheService, CacheService>();
builder.Services.AddMediatR(cfg =>
{
    cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
    cfg.AddOpenBehavior(typeof(CachingPipelineBehavior<,>));
});
{
  "code": "duplicate_request",
  "title": "Duplicate request",
  "status": 204,
  "detail": "Duplicate request with Idempotent Key 53655b3d-48d5-4ac1-ba73-4318b3b702e8."
}
Product Compatible and additional computed target framework versions.
.NET 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.

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
0.21.0 331 12/6/2024
0.20.0 247 10/12/2024
0.19.0 160 10/2/2024
0.18.0 130 9/29/2024
0.17.0 107 9/28/2024
0.16.0 130 8/20/2024
0.14.0 243 12/10/2023
0.13.0 145 12/4/2023
0.12.0 426 10/2/2022
0.11.0 460 9/24/2022
0.10.0 172 9/24/2022
0.8.0 257 9/30/2021
0.7.0 250 9/27/2021
0.6.0 415 4/10/2021
0.5.0 464 11/21/2020
0.4.0 488 11/15/2020
0.3.0 470 10/27/2020
0.2.0 523 10/12/2020
0.1.1 483 9/5/2020
0.1.0 522 9/5/2020