Class EventBusBuilder
- Namespace
- ReflectionEventing
- Assembly
- ReflectionEventing.dll
Represents a class that builds an event bus with a specific set of classConsumers.
public class EventBusBuilder
- Inheritance
-
EventBusBuilder
- Derived
- Inherited Members
- Extension Methods
Remarks
This class uses a dictionary of classConsumers where the key is the consumer type and the value is a collection of event types that the consumer can handle.
Properties
Options
Gets or sets a value indicating whether the event bus should use event polymorphism. If set to true, the event bus will deliver events to classConsumers that handle the event type or any of its base types. If set to false, the event bus will only deliver events to classConsumers that handle the exact event type. The default value is false.
public EventBusBuilderOptions Options { get; }
Property Value
Methods
AddConsumer(Type)
Adds a consumer to the builder.
public virtual EventBusBuilder AddConsumer(Type consumerType)
Parameters
consumerTypeTypeThe type of the consumer to add.
Returns
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.
BuildTypesProvider()
Builds and returns an instance of IConsumerTypesProvider based on the current configuration.
public IConsumerTypesProvider BuildTypesProvider()
Returns
- IConsumerTypesProvider
An instance of IConsumerTypesProvider. If UseEventPolymorphism is set to true, it returns an instance of HashedPolymorphicConsumerTypesProvider, otherwise it returns an instance of HashedConsumerTypesProvider.