Table of Contents

Class DependencyInjectionEventBusBuilder

Namespace
ReflectionEventing.DependencyInjection
Assembly
ReflectionEventing.DependencyInjection.dll

Represents a builder for configuring the event bus with .NET Core's built-in dependency injection.

public class DependencyInjectionEventBusBuilder : EventBusBuilder
Inheritance
DependencyInjectionEventBusBuilder
Inherited Members
Extension Methods

Constructors

DependencyInjectionEventBusBuilder(IServiceCollection)

Represents a builder for configuring the event bus with .NET Core's built-in dependency injection.

public DependencyInjectionEventBusBuilder(IServiceCollection services)

Parameters

services IServiceCollection

Methods

AddConsumer(Type)

Adds a consumer to the builder.

public override EventBusBuilder AddConsumer(Type consumerType)

Parameters

consumerType Type

The type of the consumer to add.

Returns

EventBusBuilder

Remarks

This method checks if the consumer is registered in the service collection and if it is not transient. It then gets the interfaces of the consumer that are generic and have a generic type definition of IConsumer<TEvent>. For each of these interfaces, it gets the generic argument and adds it to the classConsumers dictionary.

AddConsumer(Type, ServiceLifetime)

Adds a consumer to the event bus and IServiceCollection with a specified service lifetime.

public virtual EventBusBuilder AddConsumer(Type consumerType, ServiceLifetime lifetime)

Parameters

consumerType Type

The type of the consumer to add.

lifetime ServiceLifetime

The service lifetime of the consumer.

Returns

EventBusBuilder

The current instance of EventBusBuilder.

Exceptions

InvalidOperationException

Thrown if the consumer is already registered with a different lifetime or if the consumer is not registered in the service collection.