Table of Contents

Class Mediator

Namespace
Opossum.Mediator
Assembly
Opossum.dll

Default implementation of the mediator pattern

public sealed class Mediator : IMediator
Inheritance
Mediator
Implements
Inherited Members

Constructors

Mediator(IServiceProvider, Dictionary<Type, IMessageHandler>, ILogger<Mediator>?)

Default implementation of the mediator pattern

public Mediator(IServiceProvider serviceProvider, Dictionary<Type, IMessageHandler> handlers, ILogger<Mediator>? logger = null)

Parameters

serviceProvider IServiceProvider
handlers Dictionary<Type, IMessageHandler>
logger ILogger<Mediator>

Methods

InvokeAsync<T>(object, CancellationToken, TimeSpan?)

Execute the message handling for this message synchronously and wait for the response. The message is handled locally and delegates immediately to the appropriate handler.

public Task<T> InvokeAsync<T>(object message, CancellationToken cancellation = default, TimeSpan? timeout = null)

Parameters

message object

The message/request to process

cancellation CancellationToken

Cancellation token for async operations

timeout TimeSpan?

Optional timeout for the operation

Returns

Task<T>

The response of type T from the handler

Type Parameters

T

The expected response type