Table of Contents

Class MediatorServiceExtensions

Namespace
Arbiter.Mediation
Assembly
Arbiter.Mediation.dll

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 IServiceCollection

The IServiceCollection to add the IMediator services to.

serviceLifetime ServiceLifetime

The 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();

Remarks

This method registers the IMediator interface with the specified lifetime in the service collection. The default lifetime is Singleton.