Table of Contents

Class EventBus

Namespace
ReflectionEventing
Assembly
ReflectionEventing.dll

Represents a class that provides event publishing capabilities.

public class EventBus : IEventBus
Inheritance
EventBus
Implements
Derived
Inherited Members
Extension Methods

Remarks

This class uses a service provider to get required services and a consumer provider to get consumers for a specific event type.

Constructors

EventBus(IConsumerProvider, IConsumerTypesProvider, IEventsQueue)

Represents a class that provides event publishing capabilities.

public EventBus(IConsumerProvider consumerProviders, IConsumerTypesProvider consumerTypesProvider, IEventsQueue queue)

Parameters

consumerProviders IConsumerProvider
consumerTypesProvider IConsumerTypesProvider
queue IEventsQueue

Remarks

This class uses a service provider to get required services and a consumer provider to get consumers for a specific event type.

Methods

PublishAsync<TEvent>(TEvent, CancellationToken)

Adds the specified event to the queue.Another scope will take over execution as configured.

public virtual Task PublishAsync<TEvent>(TEvent eventItem, CancellationToken cancellationToken = default) where TEvent : class

Parameters

eventItem TEvent

The event to publish.

cancellationToken CancellationToken

A cancellation token that can be used to cancel the operation.

Returns

Task

A task that represents the asynchronous operation.

Type Parameters

TEvent

The type of the event to publish.

Remarks

The method only adds the event to the execution queue, it does not wait for its successful execution.

SendAsync<TEvent>(TEvent, CancellationToken)

Sends the specified event asynchronously within the current scope, waiting for its execution.

public virtual Task SendAsync<TEvent>(TEvent eventItem, CancellationToken cancellationToken = default) where TEvent : class

Parameters

eventItem TEvent

The event to send.

cancellationToken CancellationToken

A cancellation token that can be used to cancel the operation.

Returns

Task

A task that represents the asynchronous operation.

Type Parameters

TEvent

The type of the event to send.

Remarks

This method gets the consumers for the specified event type from the consumer provider and then uses the service provider to get the required service for each consumer. Each consumer is then used to consume the event asynchronously.