YolalMediatR 1.0.1
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package YolalMediatR --version 1.0.1
NuGet\Install-Package YolalMediatR -Version 1.0.1
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="YolalMediatR" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YolalMediatR" Version="1.0.1" />
<PackageReference Include="YolalMediatR" />
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 YolalMediatR --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: YolalMediatR, 1.0.1"
#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 YolalMediatR@1.0.1
#: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=YolalMediatR&version=1.0.1
#tool nuget:?package=YolalMediatR&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
YolalMediatR
A simple MediatR implementation for .NET that provides a mediator pattern for decoupling request/response handling.
Features
- 🚀 Simple and lightweight mediator implementation
- 🔌 Built-in dependency injection support
- 📦 Supports .NET 6.0, 7.0, 8.0, and 9.0
- ⚡ Fast handler resolution with caching
- 🎯 Type-safe request/response handling
Installation
Install the package via NuGet:
dotnet add package YolalMediatR
Or via Package Manager:
Install-Package YolalMediatR
Quick Start
1. Register Services
In your Program.cs or Startup.cs, register the mediator and handlers:
using YolalMediatR;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// Register mediator and all handlers from the current assembly
builder.Services.AddMediator(Assembly.GetExecutingAssembly());
var app = builder.Build();
2. Create a Request
Define your request class:
using YolalMediatR;
public class GetUserRequest : IRequest<UserResponse>
{
public int UserId { get; set; }
}
public class UserResponse
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
}
3. Create a Handler
Implement the handler for your request:
using YolalMediatR;
public class GetUserHandler : IRequestHandler<GetUserRequest, UserResponse>
{
public async Task<UserResponse> Handle(GetUserRequest request, CancellationToken cancellationToken = default)
{
// Your business logic here
return new UserResponse
{
Id = request.UserId,
Name = "John Doe",
Email = "john@example.com"
};
}
}
4. Use the Mediator
Inject IMediator and send requests:
using YolalMediatR;
public class UserController : ControllerBase
{
private readonly IMediator _mediator;
public UserController(IMediator mediator)
{
_mediator = mediator;
}
[HttpGet("{id}")]
public async Task<ActionResult<UserResponse>> GetUser(int id)
{
var request = new GetUserRequest { UserId = id };
var response = await _mediator.Send(request);
return Ok(response);
}
}
Advanced Usage
Registering Handlers from Multiple Assemblies
builder.Services.AddMediator(typeof(GetUserHandler).Assembly);
builder.Services.AddMediator(typeof(OrderHandler).Assembly);
Using Cancellation Tokens
var response = await _mediator.Send(request, cancellationToken);
Requirements
- .NET 6.0 or higher
- Microsoft.Extensions.DependencyInjection.Abstractions 8.0.0 or higher
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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.
-
net6.0
-
net7.0
-
net8.0
-
net9.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 |
|---|