Class MediatorServiceExtensions
Provides extension methods for registering mediation services in the service collection.
public static class MediatorServiceExtensions
- Inheritance
-
MediatorServiceExtensions
- Inherited Members
Methods
AddMediator(IServiceCollection, ServiceLifetime)
Adds IMediator services to the service collection.
public static IServiceCollection AddMediator(this IServiceCollection services, ServiceLifetime serviceLifetime = ServiceLifetime.Singleton)
Parameters
services
IServiceCollectionThe IServiceCollection to add the IMediator services to.
serviceLifetime
ServiceLifetimeThe lifetime of the IMediator service. Defaults to Singleton.
Returns
- IServiceCollection
The updated IServiceCollection so that additional calls can be chained.
Examples
The following example demonstrates how to register the mediator services:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMediator(ServiceLifetime.Singleton);
var app = builder.Build();
app.Run();