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.
#addin nuget:?package=Caravel.MediatR&version=0.21.0
                    
Install Caravel.MediatR as a Cake Addin
#tool nuget:?package=Caravel.MediatR&version=0.21.0
                    
Install Caravel.MediatR 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 314 12/6/2024
0.20.0 241 10/12/2024
0.19.0 156 10/2/2024
0.18.0 126 9/29/2024
0.17.0 103 9/28/2024
0.16.0 127 8/20/2024
0.14.0 241 12/10/2023
0.13.0 142 12/4/2023
0.12.0 416 10/2/2022
0.11.0 448 9/24/2022
0.10.0 162 9/24/2022
0.8.0 247 9/30/2021
0.7.0 239 9/27/2021
0.6.0 399 4/10/2021
0.5.0 448 11/21/2020
0.4.0 474 11/15/2020
0.3.0 456 10/27/2020
0.2.0 509 10/12/2020
0.1.1 471 9/5/2020
0.1.0 510 9/5/2020