Medino.Extensions.DependencyInjection
3.0.2
dotnet add package Medino.Extensions.DependencyInjection --version 3.0.2
NuGet\Install-Package Medino.Extensions.DependencyInjection -Version 3.0.2
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="Medino.Extensions.DependencyInjection" Version="3.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Medino.Extensions.DependencyInjection" Version="3.0.2" />
<PackageReference Include="Medino.Extensions.DependencyInjection" />
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 Medino.Extensions.DependencyInjection --version 3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Medino.Extensions.DependencyInjection, 3.0.2"
#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 Medino.Extensions.DependencyInjection@3.0.2
#: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=Medino.Extensions.DependencyInjection&version=3.0.2
#tool nuget:?package=Medino.Extensions.DependencyInjection&version=3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Medino.Extensions.DependencyInjection
Microsoft.Extensions.DependencyInjection integration for Medino mediator.
Installation
dotnet add package Medino.Extensions.DependencyInjection
Quick Start
Basic Registration
using Medino.Extensions.DependencyInjection;
var services = new ServiceCollection();
// Register Medino and scan current assembly for handlers
services.AddMedino(typeof(Program).Assembly);
var serviceProvider = services.BuildServiceProvider();
var mediator = serviceProvider.GetRequiredService<IMediator>();
Fluent Configuration
services.AddMedino(config => config
.RegisterServicesFromAssemblyContaining<Startup>()
.RegisterServicesFromAssemblyContaining<MyCommand>());
What Gets Registered
The AddMedino extension automatically scans assemblies and registers:
- Command handlers (
ICommandHandler<TCommand>) - Request handlers (
IRequestHandler<TRequest, TResponse>) - Notification handlers (
INotificationHandler<TNotification>) - Pipeline behaviors (
IPipelineBehavior<TRequest, TResponse>) - Context pipeline behaviors (
IContextPipelineBehavior<TRequest, TResponse>) - Exception handlers (
IRequestExceptionHandler<TRequest, TResponse, TException>) - Exception actions (
IRequestExceptionAction<TRequest, TException>)
All services are registered as transient by default.
Configuration Options
Register from Multiple Assemblies
services.AddMedino(
typeof(CommandsAssembly).Assembly,
typeof(QueriesAssembly).Assembly,
typeof(HandlersAssembly).Assembly);
Register by Assembly Containing Type
services.AddMedino(config => config
.RegisterServicesFromAssemblyContaining(
typeof(CreateUserCommand),
typeof(GetUserQuery)));
Register by Generic Type
services.AddMedino(config => config
.RegisterServicesFromAssemblyContaining<CreateUserCommand>()
.RegisterServicesFromAssemblyContaining<GetUserQuery>());
Example Usage
// Program.cs
var builder = WebApplication.CreateBuilder(args);
// Register Medino
builder.Services.AddMedino(typeof(Program).Assembly);
var app = builder.Build();
// Use in minimal API
app.MapPost("/users", async (CreateUserCommand command, IMediator mediator) =>
{
await mediator.SendAsync(command);
return Results.Created($"/users/{command.UserId}", null);
});
app.Run();
ASP.NET Core Integration
public class UsersController : ControllerBase
{
private readonly IMediator _mediator;
public UsersController(IMediator mediator)
{
_mediator = mediator;
}
[HttpPost]
public async Task<IActionResult> Create(CreateUserCommand command)
{
await _mediator.SendAsync(command);
return Created($"/users/{command.UserId}", null);
}
[HttpGet("{id}")]
public async Task<IActionResult> Get(int id)
{
var user = await _mediator.SendAsync(new GetUserQuery { Id = id });
return Ok(user);
}
}
Requirements
- .NET 8.0 or later
- Microsoft.Extensions.DependencyInjection.Abstractions 8.0.0 or later
Documentation
For more information about Medino and its features, see the main package.
License
MIT License - see LICENSE for details
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Medino (>= 3.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
-
net8.0
- Medino (>= 3.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
-
net9.0
- Medino (>= 3.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.