Public .NET API ReferenceL0 Foundation PrimitivesStableAOT: Full

EricksonLopez.Events

Event contracts and primitives for building decoupled, event-driven .NET applications, designed for trimming and Native AOT

26 namespaces77 types381 membersGenerated from XML docs & assemblies · UTC 2026-12-01

Showing 77 of 77 types (381 members)

EricksonLopez.Events.Attributes#

3
class

EventNameAttribute

Assembly: EricksonLopez.Events.Contracts
public sealed class EventNameAttribute : Attribute
Inherits: Attribute

Specifies the explicit, transport-stable semantic name for an event type.

Members (3)

  • constructorEventNameAttribute
    public EventNameAttribute(string name)

    Initializes a new instance of the `EventNameAttribute` class.

    name: string
    The semantic event type name (e.g., "orders.order-created").

    Exceptions: ArgumentException: `name` is `null`, empty, or consists only of white-space characters

  • methodAsEventType
    public EventType AsEventType()

    Converts the attribute name to a strongly typed `EventType`.

    Returns: A new `EventType` initialized with the configured name.

  • propertyName
    public string Name { get; }

    Gets the semantic event type name.

class

EventSourceAttribute

Assembly: EricksonLopez.Events.Contracts
public sealed class EventSourceAttribute : Attribute
Inherits: Attribute

Specifies the originating producer source or URI for an event or all events in an assembly.

Members (2)

  • constructorEventSourceAttribute
    public EventSourceAttribute(string source)

    Initializes a new instance of the `EventSourceAttribute` class.

    source: string
    The originating source identifier.

    Exceptions: ArgumentException: `source` is `null`, empty, or consists only of white-space characters

  • propertySource
    public string Source { get; }

    Gets the originating source name or URI.

class

EventVersionAttribute

Assembly: EricksonLopez.Events.Contracts
public sealed class EventVersionAttribute : Attribute
Inherits: Attribute

Specifies the explicit schema version of an event contract.

Members (3)

  • constructorEventVersionAttribute
    public EventVersionAttribute(uint version)

    Initializes a new instance of the `EventVersionAttribute` class.

    version: uint
    The version number (must be greater than or equal to 1).

    Exceptions: ArgumentOutOfRangeException: `version` is equal to zero

  • methodAsEventVersion
    public EventVersion AsEventVersion()

    Converts the attribute version to a strongly typed `EventVersion`.

    Returns: A new `EventVersion` initialized with the configured version number.

  • propertyVersion
    public uint Version { get; }

    Gets the schema version number.

EricksonLopez.Events.Bus#

1
class

EventBus

Assembly: EricksonLopez.Events
public sealed class EventBus : IEventBus
Implements: IEventBus

Provides an in-process event bus for dispatching events to registered handlers through a configurable middleware pipeline.

Remarks:

`EventBus` enforces a configurable reentrancy depth limit (`EventBusOptions.MaxReentrancyDepth`) using `Threading.AsyncLocal<T>` to prevent cyclic event cascades across asynchronous execution contexts. Middleware registered via `IEventMiddleware` is applied in the order returned by the service collection and wraps all handler dispatch, including both `EventExecutionMode.Sequential` and `EventExecutionMode.Parallel` strategies. All event handlers must be registered explicitly during startup via `EventBusServiceCollectionExtensions.AddEventHandler<TEvent, THandler>(IServiceCollection, ServiceLifetime)` or the source-generated `AddGeneratedEventHandlers()` extension. Dynamic discovery of handlers registered directly in DI as `IEventHandler<TEvent>` without explicit registration is not supported: it caused race conditions under concurrency and is incompatible with NativeAOT.

Members (3)

  • constructorEventBus
    public EventBus(IHandlerRegistry registry, IServiceProvider serviceProvider, EventBusOptions options, IEnumerable<IEventMiddleware>? middlewares = null, ILogger<EventBus>? logger = null)

    Initializes a new instance of the `EventBus` class with the specified dependencies and options.

    registry: IHandlerRegistry
    The handler registry containing event-to-handler mappings.
    serviceProvider: IServiceProvider
    The service provider for resolving scoped handler instances.
    options: EventBusOptions
    The event bus configuration options.
    middlewares: IEnumerable<IEventMiddleware>?
    The optional collection of middlewares to execute around event dispatching.
    logger: ILogger<EventBus>?
    The optional logger instance.

    Exceptions: ArgumentNullException: `registry`, `serviceProvider`, or `options` is `null`

  • methodPublishAsync<TEvent>
    public async ValueTask PublishAsync<TEvent>(TEvent eventInstance, CancellationToken cancellationToken = default) where TEvent : IEvent

    Inherits documentation from base type or interface.

    eventInstance: TEvent
    cancellationToken: CancellationToken

    Exceptions: ArgumentNullException: `eventInstance` is `null`; InvalidOperationException: The reentrancy depth limit was exceeded, or no handlers were registered and `EventBusOptions.ThrowOnUnregisteredEvent` is enabled

  • methodPublishEnvelopeAsync<TEvent>
    public async ValueTask PublishEnvelopeAsync<TEvent>(Envelopes.IEventEnvelope<TEvent> envelope, CancellationToken cancellationToken = default) where TEvent : IEvent

    Inherits documentation from base type or interface.

    envelope: Envelopes.IEventEnvelope<TEvent>
    cancellationToken: CancellationToken

EricksonLopez.Events.Bus.Configuration#

4
enum

ErrorHandlingPolicy

Assembly: EricksonLopez.Events
public enum ErrorHandlingPolicy

Specifies how exceptions arising from individual event handlers are managed during dispatch.

Members (2)

  • fieldAggregateAndContinue
    AggregateAndContinue = 1

    Executes all handlers regardless of failures and aggregates all caught exceptions.

  • fieldFailFast
    FailFast = 0

    Stops execution immediately upon encountering the first handler failure.

class

EventBusOptions

Assembly: EricksonLopez.Events
public sealed class EventBusOptions

Provides configuration options for the in-process event bus.

Members (7)

  • methodValidate
    public void Validate()

    Validates the event bus configuration options, ensuring concurrency invariants and valid depth limits.

    Exceptions: InvalidOperationException: Thrown when invalid options are configured, such as a non-positive `MaxReentrancyDepth` or a negative `MaxDegreeOfParallelism`

  • propertyErrorPolicy
    public ErrorHandlingPolicy ErrorPolicy { get; set; }

    Gets or sets the error handling policy applied when handler failures occur. The default is `ErrorHandlingPolicy.FailFast`.

  • propertyExecutionMode
    public EventExecutionMode ExecutionMode { get; set; }

    Gets or sets the execution mode for handlers dispatching the same event. The default is `EventExecutionMode.Sequential`.

  • propertyMaxDegreeOfParallelism
    public int MaxDegreeOfParallelism { get; set; }

    Gets or sets the maximum degree of parallelism when executing in parallel mode. The default is 0 (unbounded). A value greater than 0 limits concurrent handler executions.

  • propertyMaxReentrancyDepth
    public int MaxReentrancyDepth { get; set; }

    Gets or sets the maximum allowable reentrancy depth for nested event dispatch chains before throwing an exception. The default is 10.

  • propertyScopePolicy
    public HandlerScopePolicy ScopePolicy { get; set; }

    Gets or sets the dependency injection scope resolution policy for event handlers. The default is `HandlerScopePolicy.Auto`.

  • propertyThrowOnUnregisteredEvent
    public bool ThrowOnUnregisteredEvent { get; set; }

    Gets or sets a value indicating whether an exception is thrown when publishing an event with no registered handlers. The default is `false`.

enum

EventExecutionMode

Assembly: EricksonLopez.Events
public enum EventExecutionMode

Specifies how multiple handlers registered for the same event type are executed during dispatch.

Members (2)

  • fieldParallel
    Parallel = 1

    Executes handlers concurrently.

  • fieldSequential
    Sequential = 0

    Executes handlers sequentially in registration order.

enum

HandlerScopePolicy

Assembly: EricksonLopez.Events
public enum HandlerScopePolicy

Specifies the service provider scoping policy when resolving event handlers.

Members (3)

  • fieldAuto
    Auto = 0

    Automatically determines the scoping policy: creates isolated child scopes for parallel execution to ensure thread safety of scoped dependencies, and reuses ambient scope for sequential execution.

  • fieldCreatePerHandler
    CreatePerHandler = 1

    Creates an isolated `DependencyInjection.IServiceScope` for each handler invocation, disposing scoped services deterministically upon completion.

  • fieldReuseAmbientScope
    ReuseAmbientScope = 2

    Reuses the ambient `System.IServiceProvider` scope provided by the caller without creating new scopes.

    WARNING: When used with parallel execution mode, concurrent handlers will share the ambient scope, which can cause concurrency conflicts on non-thread-safe scoped dependencies (such as Entity Framework Core DbContext). For parallel execution, `Auto` or `CreatePerHandler` is strongly recommended.

EricksonLopez.Events.Bus.Diagnostics#

1
class

EventBusDiagnostics

Assembly: EricksonLopez.Events
public static class EventBusDiagnostics

Provides OpenTelemetry ActivitySource and Metrics instruments for the EventBus.

Members (5)

  • methodRecordPublish
    public static void RecordPublish(string eventType, double durationMs, int handlerCount, bool success)

    Records telemetry metrics for a completed event publication.

    eventType: string
    The type name of the event.
    durationMs: double
    The elapsed dispatch time in milliseconds.
    handlerCount: int
    The number of handlers executed.
    success: bool
    `true` if dispatch completed successfully; otherwise, `false`.
  • methodStartPublishActivity<TEvent>
    public static Activity? StartPublishActivity<TEvent>(TEvent eventInstance) where TEvent : IEvent

    Starts an OpenTelemetry activity for event publication.

    eventInstance: TEvent
    The event instance to trace.

    Returns: An active `Activity` if listeners are configured; otherwise, `null`.

    Type parameters: TEvent: The type of the event being published.

  • propertyTagRedactor
    public static Func<string, object?, object?>? TagRedactor { get; set; }

    Gets or sets an optional tag redactor or sanitizer delegate for telemetry tags (e.g. tenant.id, correlation.id).

  • fieldSourceName
    public const string SourceName

    Gets the canonical name of the EventBus telemetry source and meter.

  • fieldSourceVersion
    public const string SourceVersion

    Gets the current version of the EventBus telemetry source.

EricksonLopez.Events.Bus.Exceptions#

1
class

EventDispatchException

Assembly: EricksonLopez.Events
public sealed class EventDispatchException : AggregateException
Inherits: AggregateException

Represents errors that occur when one or more event handlers fail during event dispatch.

Members (3)

  • constructorEventDispatchException
    public EventDispatchException(Type eventType, IEnumerable<Exception> innerExceptions)

    Initializes a new instance of the `EventDispatchException` class for the specified event type and handler exceptions.

    eventType: Type
    The type of the event that failed dispatch.
    innerExceptions: IEnumerable<Exception>
    The collection of exceptions thrown by individual handlers.
  • constructorEventDispatchException
    public EventDispatchException(Type eventType, string message, IEnumerable<Exception> innerExceptions)

    Initializes a new instance of the `EventDispatchException` class with a specified error message.

    eventType: Type
    The type of the event that failed dispatch.
    message: string
    The error message that explains the reason for the exception.
    innerExceptions: IEnumerable<Exception>
    The collection of exceptions thrown by individual handlers.
  • propertyEventType
    public Type EventType { get; }

    Gets the type of the event that failed to be dispatched.

EricksonLopez.Events.Bus.Execution#

3
interface

IExecutionStrategy

Assembly: EricksonLopez.Events
public interface IExecutionStrategy

Defines a strategy for executing event handlers during dispatch.

Members (1)

  • methodExecuteAsync<TEvent>
    ValueTask ExecuteAsync<TEvent>(IReadOnlyList<HandlerDescriptor> handlers, TEvent eventInstance, IServiceProvider serviceProvider, EventBusOptions options, CancellationToken cancellationToken) where TEvent : IEvent

    Executes registered handlers for the specified event.

    handlers: IReadOnlyList<HandlerDescriptor>
    The descriptors of registered handlers.
    eventInstance: TEvent
    The event instance to dispatch.
    serviceProvider: IServiceProvider
    The service provider used to resolve handler dependencies.
    options: EventBusOptions
    The event bus configuration options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous operation.

    Type parameters: TEvent: The type of the event to handle.

class

ParallelExecutionStrategy

Assembly: EricksonLopez.Events
public sealed class ParallelExecutionStrategy : IExecutionStrategy
Implements: IExecutionStrategy

Executes all registered handlers for an event concurrently, collecting and aggregating any handler exceptions into a single `EventDispatchException`, or failing fast if configured.

Members (1)

  • methodExecuteAsync<TEvent>
    public async ValueTask ExecuteAsync<TEvent>(IReadOnlyList<HandlerDescriptor> handlers, TEvent eventInstance, IServiceProvider serviceProvider, EventBusOptions options, CancellationToken cancellationToken) where TEvent : IEvent

    Executes registered handlers for the specified event.

    handlers: IReadOnlyList<HandlerDescriptor>
    The descriptors of registered handlers.
    eventInstance: TEvent
    The event instance to dispatch.
    serviceProvider: IServiceProvider
    The service provider used to resolve handler dependencies.
    options: EventBusOptions
    The event bus configuration options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous operation.

    Type parameters: TEvent: The type of the event to handle.

class

SequentialExecutionStrategy

Assembly: EricksonLopez.Events
public sealed class SequentialExecutionStrategy : IExecutionStrategy
Implements: IExecutionStrategy

Executes registered handlers for an event one at a time in registration order, applying the configured `ErrorHandlingPolicy` upon handler failures.

Members (1)

  • methodExecuteAsync<TEvent>
    public async ValueTask ExecuteAsync<TEvent>(IReadOnlyList<HandlerDescriptor> handlers, TEvent eventInstance, IServiceProvider serviceProvider, EventBusOptions options, CancellationToken cancellationToken) where TEvent : IEvent

    Executes registered handlers for the specified event.

    handlers: IReadOnlyList<HandlerDescriptor>
    The descriptors of registered handlers.
    eventInstance: TEvent
    The event instance to dispatch.
    serviceProvider: IServiceProvider
    The service provider used to resolve handler dependencies.
    options: EventBusOptions
    The event bus configuration options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous operation.

    Type parameters: TEvent: The type of the event to handle.

EricksonLopez.Events.Bus.Extensions#

2
class

EventBusServiceCollectionExtensions

Assembly: EricksonLopez.Events
public static class EventBusServiceCollectionExtensions

Provides extension methods for registering `IEventBus` and related eventing services in an `IServiceCollection`.

Members (4)

  • methodAddEnvelopeEventHandler<TEvent, THandler>
    public static IServiceCollection AddEnvelopeEventHandler<TEvent, THandler>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Scoped) where TEvent : IEvent where THandler : class, IEnvelopeEventHandler<TEvent>

    Registers a strongly typed envelope event handler into the service collection and handler registry.

    services: this IServiceCollection
    The `IServiceCollection` to configure.
    lifetime: ServiceLifetime
    The service lifetime for the handler. The default is `ServiceLifetime.Scoped`.

    Returns: The configured `IServiceCollection` instance.

    Type parameters: TEvent: The type of event contained in the envelope to handle.; THandler: The type of the envelope event handler implementation. Exceptions: ArgumentNullException: `services` is `null`

  • methodAddEventBus
    public static IServiceCollection AddEventBus(this IServiceCollection services, Action<EventBusOptions>? configure = null)

    Registers core event bus services into the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to configure.
    configure: Action<EventBusOptions>?
    An optional delegate to configure `EventBusOptions`.

    Returns: The configured `IServiceCollection` instance.

    This method registers the following services: - `IHandlerRegistry` as a singleton, populated from registered `HandlerRegistrationToken` instances. - `IEventBus` as scoped (resolved once per DI scope, typically per HTTP request). - `IEventPublisher` as scoped, delegating to the same `IEventBus` instance. Exceptions: ArgumentNullException: `services` is `null`

  • methodAddEventHandler<TEvent, THandler>
    public static IServiceCollection AddEventHandler<TEvent, THandler>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Scoped) where TEvent : IEvent where THandler : class, IEventHandler<TEvent>

    Registers a strongly typed event handler into the service collection and handler registry.

    services: this IServiceCollection
    The `IServiceCollection` to configure.
    lifetime: ServiceLifetime
    The service lifetime for the handler. The default is `ServiceLifetime.Scoped`.

    Returns: The configured `IServiceCollection` instance.

    Type parameters: TEvent: The type of event to handle.; THandler: The type of the event handler implementation. Exceptions: ArgumentNullException: `services` is `null`

  • methodAddEventMiddleware<TMiddleware>
    public static IServiceCollection AddEventMiddleware<TMiddleware>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Transient) where TMiddleware : class, IEventMiddleware

    Registers an event middleware into the pipeline with the specified lifetime.

    services: this IServiceCollection
    The `IServiceCollection` to configure.
    lifetime: ServiceLifetime
    The service lifetime for the middleware. The default is `ServiceLifetime.Transient`.

    Returns: The configured `IServiceCollection` instance.

    EVT-HIGH-004: Singleton lifetime for stateful middlewares is dangerous because the middleware instance is shared across all concurrent handlers. For example, `CausationDepthLimitMiddleware` uses `Threading.AsyncLocal<T>` and is safe as Singleton; however, any middleware with mutable instance fields that is not thread-safe must use `ServiceLifetime.Transient` or `ServiceLifetime.Scoped`. Use `ServiceLifetime.Transient` (default) for stateful middlewares. Use `ServiceLifetime.Singleton` only for stateless or `Threading.AsyncLocal<T>`-based middlewares. Type parameters: TMiddleware: The type of the event middleware implementation. Exceptions: ArgumentNullException: `services` is `null`; InvalidOperationException: `lifetime` is `ServiceLifetime.Singleton` and `TMiddleware` is not annotated with `[ThreadSafe]` or contains mutable fields — Singleton middlewares are shared across all concurrent requests and must be fully thread-safe

class

HandlerRegistrationToken

Assembly: EricksonLopez.Events
public sealed class HandlerRegistrationToken

Token used to transfer handler registrations into the singleton `HandlerRegistry`.

Members (3)

  • constructorHandlerRegistrationToken
    public HandlerRegistrationToken(Type eventType, HandlerDescriptor descriptor)

    Initializes a new instance of the `HandlerRegistrationToken` class.

    eventType: Type
    The type of the event.
    descriptor: HandlerDescriptor
    The handler descriptor.
  • propertyDescriptor
    public HandlerDescriptor Descriptor { get; }

    Gets the handler descriptor containing dispatch metadata and static invoker delegate.

  • propertyEventType
    public Type EventType { get; }

    Gets the type of the event handled by this registration.

EricksonLopez.Events.Bus.Middleware#

4
class

CausationDepthLimitMiddleware

Assembly: EricksonLopez.Events
public sealed class CausationDepthLimitMiddleware : IEventMiddleware
Implements: IEventMiddleware

Provides a middleware that guards against distributed causality loops or runaway reentrancy chains by tracking causation depth monotonically using `Threading.AsyncLocal<T>`.

Remarks:

The causation depth is maintained internally via an `Threading.AsyncLocal<T>` counter that increments with each nested event publication. It is never read from or written to envelope headers on the incoming side — only propagated outward for cross-service correlation. This design prevents ATK-001: an attacker injecting `X-Causation-Depth: 0` in `EventMetadata.CustomHeaders` cannot reset the depth counter because the middleware always uses the `Threading.AsyncLocal<T>` value, not the header.

Members (4)

  • constructorCausationDepthLimitMiddleware
    public CausationDepthLimitMiddleware(int maxDepth = 16)

    Initializes a new instance of the `CausationDepthLimitMiddleware` class.

    maxDepth: int
    The maximum allowable causation depth. Must be greater than zero.

    Exceptions: ArgumentOutOfRangeException: `maxDepth` is less than or equal to zero

  • methodInvokeAsync<TEvent>
    public async ValueTask InvokeAsync<TEvent>(TEvent eventInstance, EventMiddlewareDelegate<TEvent> nextHandler, CancellationToken cancellationToken) where TEvent : IEvent

    Executes the middleware processing logic around event publication.

    eventInstance: TEvent
    The event instance being dispatched.
    nextHandler: EventMiddlewareDelegate<TEvent>
    The delegate representing the next middleware or terminal handler in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous operation.

    Type parameters: TEvent: The type of the event being dispatched.

  • propertyMaxDepth
    public int MaxDepth { get; }

    Gets the maximum allowed causation depth before publication is rejected. The default is 16.

  • fieldCausationDepthHeaderName
    public const string CausationDepthHeaderName

    Represents the default header name used to convey causality depth across transport boundaries.

delegate

EventMiddlewareDelegate<TEvent>

Assembly: EricksonLopez.Events
public delegate ValueTask EventMiddlewareDelegate<TEvent>(TEvent eventInstance, CancellationToken cancellationToken) where TEvent : IEvent
Inherits: System.MulticastDelegate

Encapsulates an asynchronous operation that processes an event within the middleware execution pipeline.

Remarks:

Type parameters: TEvent: The type of the event being processed.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

IEventMiddleware

Assembly: EricksonLopez.Events
public interface IEventMiddleware

Defines a middleware component that intercepts event dispatch execution.

Members (1)

  • methodInvokeAsync<TEvent>
    ValueTask InvokeAsync<TEvent>(TEvent eventInstance, EventMiddlewareDelegate<TEvent> nextHandler, CancellationToken cancellationToken) where TEvent : IEvent

    Executes the middleware processing logic around event publication.

    eventInstance: TEvent
    The event instance being dispatched.
    nextHandler: EventMiddlewareDelegate<TEvent>
    The delegate representing the next middleware or terminal handler in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous operation.

    Type parameters: TEvent: The type of the event being dispatched.

class

MiddlewarePipeline

Assembly: EricksonLopez.Events
public static class MiddlewarePipeline

Provides methods for constructing middleware execution pipelines for event dispatch.

Members (1)

  • methodBuild<TEvent>
    public static EventMiddlewareDelegate<TEvent> Build<TEvent>(IReadOnlyList<IEventMiddleware> middlewares, EventMiddlewareDelegate<TEvent> terminal) where TEvent : IEvent

    Chains a collection of middlewares around a terminal execution delegate.

    middlewares: IReadOnlyList<IEventMiddleware>
    The collection of middleware instances to chain.
    terminal: EventMiddlewareDelegate<TEvent>
    The terminal execution delegate that dispatches to handlers.

    Returns: A composed `EventMiddlewareDelegate<TEvent>` pipeline delegate.

    Type parameters: TEvent: The type of event being dispatched. Exceptions: ArgumentNullException: `terminal` is `null`

EricksonLopez.Events.Bus.Registry#

4
class

HandlerDescriptor

Assembly: EricksonLopez.Events
public sealed class HandlerDescriptor

Represents a registered event handler and its invocation metadata.

Members (5)

  • constructorHandlerDescriptor
    public HandlerDescriptor(Type handlerType, Type serviceType, Func<object, object, CancellationToken, ValueTask> invoker, object? typedInvoker = null)

    Initializes a new instance of the `HandlerDescriptor` class with the specified types, invocation delegate, and optional typed invoker.

    handlerType: Type
    The concrete handler implementation type.
    serviceType: Type
    The service interface type.
    invoker: Func<object, object, CancellationToken, ValueTask>
    The invoker delegate.
    typedInvoker: object?
    The optional strongly typed invoker delegate.

    Exceptions: ArgumentNullException: `handlerType`, `serviceType`, or `invoker` is `null`

  • propertyHandlerType
    public Type HandlerType { get; }

    Gets the concrete implementation type of the handler.

  • propertyInvoker
    public Func<object, object, CancellationToken, ValueTask> Invoker { get; }

    Gets the invocation delegate that executes the handler asynchronously.

  • propertyServiceType
    public Type ServiceType { get; }

    Gets the resolved service interface type.

  • propertyTypedInvoker
    public object? TypedInvoker { get; }

    Gets the strongly typed invocation delegate, if available, avoiding boxing for value-type events.

delegate

HandlerInvoker<TEvent>

Assembly: EricksonLopez.Events
public delegate ValueTask HandlerInvoker<TEvent>(object handler, TEvent event, CancellationToken cancellationToken)
Inherits: System.MulticastDelegate

Encapsulates a method that asynchronously invokes a handler instance with the given event payload.

Remarks:

Type parameters: TEvent: The type of event being handled.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

class

HandlerRegistry

Assembly: EricksonLopez.Events
public sealed class HandlerRegistry : IHandlerRegistry
Implements: IHandlerRegistry

Provides a thread-safe registry for storing and resolving event handler descriptors.

Members (3)

  • methodGetHandlers
    public IReadOnlyList<HandlerDescriptor> GetHandlers(Type eventType)

    Retrieves registered handler descriptors for the specified event type.

    eventType: Type
    The type of the event.

    Returns: A read-only list of handler descriptors, or an empty list if none are registered.

    Exceptions: ArgumentNullException: `eventType` is `null`

  • methodHasHandlers
    public bool HasHandlers(Type eventType)

    Determines whether any handlers are registered for the specified event type.

    eventType: Type
    The type of the event.

    Returns: `true` if at least one handler is registered; otherwise, `false`.

    Exceptions: ArgumentNullException: `eventType` is `null`

  • methodRegister
    public void Register(Type eventType, HandlerDescriptor descriptor)

    Registers a handler descriptor for the specified event type.

    eventType: Type
    The type of the event.
    descriptor: HandlerDescriptor
    The handler descriptor to register.

    Exceptions: ArgumentNullException: `eventType` or `descriptor` is `null`

interface

IHandlerRegistry

Assembly: EricksonLopez.Events
public interface IHandlerRegistry

Defines a registry that provides read-only access to registered event handler descriptors.

Members (2)

  • methodGetHandlers
    IReadOnlyList<HandlerDescriptor> GetHandlers(Type eventType)

    Retrieves registered handler descriptors for the specified event type.

    eventType: Type
    The type of the event.

    Returns: A read-only list of handler descriptors, or an empty list if none are registered.

    Exceptions: ArgumentNullException: `eventType` is `null`

  • methodHasHandlers
    bool HasHandlers(Type eventType)

    Determines whether any handlers are registered for the specified event type.

    eventType: Type
    The type of the event.

    Returns: `true` if at least one handler is registered; otherwise, `false`.

    Exceptions: ArgumentNullException: `eventType` is `null`

EricksonLopez.Events.CloudEvents#

2
class

CloudEventExtensions

Assembly: EricksonLopez.Events.CloudEvents
public static class CloudEventExtensions

Provides extension methods for converting between `EventEnvelope<TEvent>` and `CloudEvent<TData>`.

Members (2)

  • methodToCloudEvent<TEvent>
    public static CloudEvent<TEvent> ToCloudEvent<TEvent>(this EventEnvelope<TEvent> envelope, Uri? defaultSource = null, Uri? schemaBaseUri = null) where TEvent : IEvent

    Converts a strongly-typed `EventEnvelope<TEvent>` into a `CloudEvent<TEvent>`.

    envelope: this EventEnvelope<TEvent>
    The event envelope instance to convert.
    defaultSource: Uri?
    The fallback producer source URI used when metadata does not contain a valid source.
    schemaBaseUri: Uri?
    The optional base URI for constructing the dataschema URI.

    Returns: A new `CloudEvent<TEvent>` instance.

    Type parameters: TEvent: The type of the event payload. Exceptions: ArgumentNullException: `envelope` is `null`

  • methodToEventEnvelope<TEvent>
    public static EventEnvelope<TEvent> ToEventEnvelope<TEvent>(this CloudEvent<TEvent> cloudEvent) where TEvent : IEvent

    Converts a `CloudEvent<TEvent>` into a strongly-typed `EventEnvelope<TEvent>`.

    cloudEvent: this CloudEvent<TEvent>
    The cloud event instance to convert.

    Returns: A new `EventEnvelope<TEvent>` instance.

    Type parameters: TEvent: The type of the event payload. Exceptions: ArgumentNullException: `cloudEvent` is `null`

record

CloudEvent<TData>

Assembly: EricksonLopez.Events.CloudEvents
public sealed record CloudEvent<TData>

Represents an immutable CloudEvents v1.0 specification event message.

Remarks:

Type parameters: TData: The type of the event payload data.

Members (14)

  • constructorCloudEvent
    public CloudEvent(string id, Uri source, string type, TData data, DateTimeOffset? time = null, string? dataContentType = "", Uri? dataSchema = null, string? correlationId = null, string? causationId = null, string? tenantId = null)

    Initializes a new instance of the `CloudEvent<TData>` class.

    id: string
    The unique event identifier.
    source: Uri
    The originating producer source URI.
    type: string
    The semantic event type name.
    data: TData
    The event payload data.
    time: DateTimeOffset?
    The optional occurrence timestamp.
    dataContentType: string?
    The optional data MIME content type.
    dataSchema: Uri?
    The optional data schema URI.
    correlationId: string?
    The optional correlation identifier.
    causationId: string?
    The optional causation identifier.
    tenantId: string?
    The optional tenant identifier.

    Exceptions: ArgumentException: `id` or `type` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `source` or `data` is `null`

  • constructorCloudEvent
    public CloudEvent(string id, Uri source, string type, TData data, DateTimeOffset? time, string? dataContentType, Uri? dataSchema, string? correlationId, string? causationId, string? tenantId, Dictionary<string, object?>? extensionAttributes)

    Initializes a new instance of the `CloudEvent<TData>` class with explicit extension attributes.

    id: string
    The unique event identifier.
    source: Uri
    The originating producer source URI.
    type: string
    The semantic event type name.
    data: TData
    The event payload data.
    time: DateTimeOffset?
    The optional occurrence timestamp.
    dataContentType: string?
    The optional data MIME content type.
    dataSchema: Uri?
    The optional data schema URI.
    correlationId: string?
    The optional correlation identifier.
    causationId: string?
    The optional causation identifier.
    tenantId: string?
    The optional tenant identifier.
    extensionAttributes: Dictionary<string, object?>?
    The optional dictionary of custom extension attributes.

    Exceptions: ArgumentException: `id` or `type` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `source` or `data` is `null`

  • propertyCausationId
    public string? CausationId { get; init; }

    Gets the causation identifier extension attribute.

  • propertyCorrelationId
    public string? CorrelationId { get; init; }

    Gets the correlation identifier extension attribute.

  • propertyData
    public TData Data { get; init; }

    Gets the domain-specific event payload.

  • propertyDataContentType
    public string? DataContentType { get; init; }

    Gets the content type of data value.

  • propertyDataSchema
    public Uri? DataSchema { get; init; }

    Gets the URI that identifies the schema that data adheres to.

  • propertyExtensionAttributes
    public Dictionary<string, object?>? ExtensionAttributes { get; set; }

    Gets any additional extension attributes.

  • propertyId
    public string Id { get; init; }

    Gets the unique identifier for the event.

  • propertySource
    public Uri Source { get; init; }

    Gets the context in which an event happened (URI-reference).

  • propertySpecVersion
    public string SpecVersion { get; }

    Gets the CloudEvents specification version. Always "1.0".

  • propertyTenantId
    public string? TenantId { get; init; }

    Gets the tenant identifier extension attribute.

  • propertyTime
    public DateTimeOffset? Time { get; init; }

    Gets the timestamp of when the occurrence happened.

  • propertyType
    public string Type { get; init; }

    Gets the type of event related to the originating occurrence.

EricksonLopez.Events.CloudEvents.Serialization#

1
class

CloudEventsJsonSerializerOptionsExtensions

Assembly: EricksonLopez.Events.CloudEvents
public static class CloudEventsJsonSerializerOptionsExtensions

Provides extension methods for configuring `JsonSerializerOptions` with CloudEvents options.

Members (1)

  • methodConfigureForCloudEvents
    public static JsonSerializerOptions ConfigureForCloudEvents(this JsonSerializerOptions options)

    Configures `JsonSerializerOptions` with CloudEvents v1.0 standard settings.

    options: this JsonSerializerOptions
    The `JsonSerializerOptions` to configure.

    Returns: The configured `JsonSerializerOptions` instance.

    Exceptions: ArgumentNullException: `options` is `null`

EricksonLopez.Events.Context#

2
class

EventContext

Assembly: EricksonLopez.Events.Contracts
public static class EventContext

Provides ambient context for the event envelope currently being processed within the asynchronous execution flow.

Members (10)

  • methodIsHandlerCompleted
    public static bool IsHandlerCompleted(EventId eventId, Type handlerType)

    Determines whether the specified handler has already completed processing for the given event ID.

    eventId: EventId
    The unique event identifier.
    handlerType: Type
    The type of the event handler.

    Returns: `true` if the handler has completed processing; otherwise, `false`.

  • methodMarkHandlerCompleted
    public static void MarkHandlerCompleted(EventId eventId, Type handlerType)

    Marks the specified handler as completed processing for the given event ID.

    eventId: EventId
    The unique event identifier.
    handlerType: Type
    The type of the event handler.
  • methodSetCurrent
    public static IDisposable SetCurrent(IEventEnvelope? envelope)

    Sets the current event envelope within an ambient asynchronous scope.

    envelope: IEventEnvelope?
    The event envelope to attach to the ambient context.

    Returns: A disposable scope that restores the previous ambient envelope upon disposal.

  • methodSetExecutionTracker
    public static IDisposable SetExecutionTracker(IEventExecutionTracker? tracker)

    Sets the current event execution tracker within an ambient asynchronous scope.

    tracker: IEventExecutionTracker?
    The event execution tracker to attach.

    Returns: A disposable scope that restores the previous tracker upon disposal.

  • propertyCausationId
    public static CausationId? CausationId { get; }

    Gets the causation identifier of the current event, or `null`.

  • propertyCorrelationId
    public static CorrelationId? CorrelationId { get; }

    Gets the correlation identifier of the current event, or `null`.

  • propertyCurrent
    public static IEventEnvelope? Current { get; }

    Gets the envelope of the event currently being processed, or `null` if no event envelope is active.

  • propertyExecutionTracker
    public static IEventExecutionTracker? ExecutionTracker { get; }

    Gets the ambient event execution tracker, or `null` if no tracker is active.

  • propertyMetadata
    public static EventMetadata? Metadata { get; }

    Gets the ambient event metadata of the event currently being processed, or `null`.

  • propertyTenantId
    public static TenantId? TenantId { get; }

    Gets the tenant identifier of the current event, or `null`.

interface

IEventExecutionTracker

Assembly: EricksonLopez.Events.Contracts
public interface IEventExecutionTracker

Defines a contract for tracking completed handler executions per event during dispatch, enabling idempotent retries in transactional and resilient pipelines.

Members (2)

  • methodIsCompleted
    bool IsCompleted(EventId eventId, Type handlerType)

    Determines whether the specified handler type has already completed processing for the given event ID.

    eventId: EventId
    The event identifier.
    handlerType: Type
    The handler implementation or interface type.

    Returns: `true` if already completed; otherwise, `false`.

  • methodMarkCompleted
    void MarkCompleted(EventId eventId, Type handlerType)

    Records that the specified handler type has completed processing for the given event ID.

    eventId: EventId
    The event identifier.
    handlerType: Type
    The handler implementation or interface type.

EricksonLopez.Events.Contracts#

9
class

EventPublisherExtensions

Assembly: EricksonLopez.Events
public static class EventPublisherExtensions

Provides extension methods for `IEventPublisher`.

Members (2)

  • methodPublishAsync<TEvent>
    public static ValueTask PublishAsync<TEvent>(this IEventPublisher publisher, EventEnvelope<TEvent> envelope, CancellationToken cancellationToken = default) where TEvent : IEvent

    Publishes an event wrapped in an `EventEnvelope<TEvent>` to registered subscribers asynchronously.

    publisher: this IEventPublisher
    The event publisher instance.
    envelope: EventEnvelope<TEvent>
    The envelope wrapping the event payload to publish.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous operation.

    Type parameters: TEvent: The type of the event contained in the envelope. Exceptions: ArgumentNullException: `publisher` or `envelope` is `null`

  • methodPublishAsync<TEvent>
    public static ValueTask PublishAsync<TEvent>(this IEventPublisher publisher, IEventEnvelope<TEvent> envelope, CancellationToken cancellationToken = default) where TEvent : IEvent

    Publishes an event wrapped in an `IEventEnvelope<TEvent>` to registered subscribers asynchronously.

    publisher: this IEventPublisher
    The event publisher instance.
    envelope: IEventEnvelope<TEvent>
    The envelope wrapping the event payload to publish.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous operation.

    Type parameters: TEvent: The type of the event contained in the envelope. Exceptions: ArgumentNullException: `publisher` or `envelope` is `null`

interface

IDomainEvent

Assembly: EricksonLopez.Events.Contracts
public interface IDomainEvent : IEvent
Implements: IEvent

Represents a domain event that captures a significant state change within an aggregate root or bounded context, expressed using the Ubiquitous Language of the domain.

Remarks:

Domain events are internal to a bounded context and must not be exposed directly across context boundaries. Use `IIntegrationEvent` for cross-context communication.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

IEnvelopeEventHandler<TEvent>

Assembly: EricksonLopez.Events.Contracts
public interface IEnvelopeEventHandler<TEvent> where TEvent : IEvent

Defines a handler for processing events wrapped in an `IEventEnvelope<TEvent>` carrying ambient metadata and transport headers.

Remarks:

Type parameters: TEvent: The type of the event contained in the envelope.

Members (1)

  • methodHandleAsync
    ValueTask HandleAsync(IEventEnvelope<TEvent> envelope, CancellationToken cancellationToken = default)

    Handles the event envelope asynchronously.

    envelope: IEventEnvelope<TEvent>
    The event envelope carrying payload and metadata.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous operation.

interface

IEvent

Assembly: EricksonLopez.Events.Contracts
public interface IEvent

Defines the core contract for all events within the application ecosystem.

Members (2)

  • propertyId
    EventId Id { get; }

    Gets the unique identifier of this event instance.

  • propertyOccurredAt
    DateTimeOffset OccurredAt { get; }

    Gets the UTC timestamp at which the event occurrence was recorded.

interface

IEventBus

Assembly: EricksonLopez.Events.Contracts
public interface IEventBus : IEventPublisher
Implements: IEventPublisher

Defines the in-process event bus for publishing events across decoupled application boundaries.

Remarks:

Combines `IEventPublisher` into a single entry point for in-process event dispatch. Implementations are expected to dispatch published events to all registered `IEventHandler<TEvent>` instances.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

IEventHandler<TEvent>

Assembly: EricksonLopez.Events.Contracts
public interface IEventHandler<TEvent> where TEvent : IEvent

Defines a strongly typed asynchronous handler for a specific event type.

Remarks:

Type parameters: TEvent: The type of event this handler processes. Must implement `IEvent`.

Members (1)

  • methodHandleAsync
    ValueTask HandleAsync(TEvent eventInstance, CancellationToken cancellationToken = default)

    Handles the specified event asynchronously.

    eventInstance: TEvent
    The event instance to process. Must not be `null`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous handling operation.

interface

IEventPublisher

Assembly: EricksonLopez.Events.Contracts
public interface IEventPublisher

Defines a contract for publishing events within the application.

Members (2)

  • methodPublishAsync<TEvent>
    ValueTask PublishAsync<TEvent>(TEvent eventInstance, CancellationToken cancellationToken = default) where TEvent : IEvent

    Publishes an event to all registered subscribers asynchronously.

    eventInstance: TEvent
    The event instance to publish. Must not be `null`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous publish operation.

    Type parameters: TEvent: The concrete event type to publish. Must implement `IEvent`.

  • methodPublishEnvelopeAsync<TEvent>
    async ValueTask PublishEnvelopeAsync<TEvent>(Envelopes.IEventEnvelope<TEvent> envelope, CancellationToken cancellationToken = default) where TEvent : IEvent

    Publishes an event wrapped in an envelope carrying ambient metadata to all registered subscribers asynchronously.

    envelope: Envelopes.IEventEnvelope<TEvent>
    The event envelope carrying payload and ambient metadata. Must not be `null`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous publish operation.

    Type parameters: TEvent: The concrete event type to publish. Must implement `IEvent`.

interface

IEventSubscriber

Assembly: EricksonLopez.Events.Contracts
public interface IEventSubscriber

Defines a contract for registering and managing in-memory event handlers.

Members (4)

  • methodSubscribe<TEvent>
    void Subscribe<TEvent>(IEnvelopeEventHandler<TEvent> handler) where TEvent : IEvent

    Registers an envelope handler instance to receive event envelopes of the specified type.

    handler: IEnvelopeEventHandler<TEvent>
    The envelope handler instance to register. Must not be `null`.

    Type parameters: TEvent: The event payload type to subscribe to.

  • methodSubscribe<TEvent>
    void Subscribe<TEvent>(IEventHandler<TEvent> handler) where TEvent : IEvent

    Registers a handler instance to receive events of the specified type.

    handler: IEventHandler<TEvent>
    The handler instance to register. Must not be `null`.

    Type parameters: TEvent: The event type to subscribe to.

  • methodUnsubscribe<TEvent>
    void Unsubscribe<TEvent>(IEnvelopeEventHandler<TEvent> handler) where TEvent : IEvent

    Removes a previously registered envelope handler from receiving event envelopes of the specified type.

    handler: IEnvelopeEventHandler<TEvent>
    The envelope handler instance to remove. Must not be `null`.

    Type parameters: TEvent: The event payload type to unsubscribe from.

  • methodUnsubscribe<TEvent>
    void Unsubscribe<TEvent>(IEventHandler<TEvent> handler) where TEvent : IEvent

    Removes a previously registered handler from receiving events of the specified type.

    handler: IEventHandler<TEvent>
    The handler instance to remove. Must not be `null`.

    Type parameters: TEvent: The event type to unsubscribe from.

interface

IIntegrationEvent

Assembly: EricksonLopez.Events.Contracts
public interface IIntegrationEvent : IEvent
Implements: IEvent

Represents an integration event published across bounded context or network boundaries. Integration events are versioned, public contracts decoupled from internal domain entities.

Remarks:

Integration events must be stable, self-contained, and serialization-safe. They must not embed `IDomainEvent` types or internal domain models.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

EricksonLopez.Events.Diagnostics#

1
class

EventsDiagnostics

Assembly: EricksonLopez.Events
public static class EventsDiagnostics

Provides zero-cost OpenTelemetry instrumentation, distributed tracing, and metrics for event operations.

Members (7)

  • methodRecordEventHandled
    public static void RecordEventHandled(string eventType, double durationMs, bool success)

    Records a handled event metric with its duration and outcome.

    eventType: string
    The type name of the event.
    durationMs: double
    The execution duration in milliseconds.
    success: bool
    `true` if handling succeeded; otherwise, `false`.
  • methodRecordEventPublished
    public static void RecordEventPublished(string eventType)

    Records a published event metric.

    eventType: string
    The type name of the event.
  • methodStartPublishActivity<TEvent>
    public static Activity? StartPublishActivity<TEvent>(TEvent event, EventMetadata? metadata = null) where TEvent : IEvent

    Starts an activity for an event publication if tracing listeners are active.

    event: TEvent
    The event instance being published.
    metadata: EventMetadata?
    The optional ambient metadata associated with the event.

    Returns: An active `Activity` if listeners are configured; otherwise, `null`.

    Type parameters: TEvent: The type of the event being published.

  • fieldActivitySource
    public static readonly ActivitySource ActivitySource

    Gets the `Diagnostics.ActivitySource` for distributed tracing of event operations.

  • fieldMeter
    public static readonly Meter Meter

    Gets the `Metrics.Meter` for recording event metrics.

  • fieldSourceName
    public const string SourceName

    Gets the name of the instrumentation source.

  • fieldVersion
    public const string Version

    Gets the version of the instrumentation source.

EricksonLopez.Events.Dispatch#

1
class

InMemoryEventPublisher

Assembly: EricksonLopez.Events
public sealed class InMemoryEventPublisher : IEventPublisher, IEventSubscriber
Implements: IEventPublisher, IEventSubscriber

Provides a lightweight in-memory event publisher and subscriber backed by a copy-on-write subscription list.

Remarks:

Subscriptions and publications are thread-safe. The copy-on-write strategy ensures that iterating over handlers during `PublishAsync` is not affected by concurrent calls to `Subscribe<TEvent>(IEventHandler<TEvent>)` or `Unsubscribe<TEvent>(IEventHandler<TEvent>)`. Handlers are invoked sequentially in subscription order. Exceptions from individual handlers propagate immediately and abort processing of remaining handlers for that publish call.

Members (7)

  • methodPublishAsync<TEvent>
    public async ValueTask PublishAsync<TEvent>(TEvent eventInstance, CancellationToken cancellationToken = default) where TEvent : IEvent

    Publishes an event to all registered subscribers asynchronously.

    eventInstance: TEvent
    The event instance to publish. Must not be `null`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous publish operation.

    Type parameters: TEvent: The concrete event type to publish. Must implement `IEvent`. Exceptions: ArgumentNullException: `eventInstance` is `null`; InvalidOperationException: The reentrancy depth limit was exceeded

  • methodPublishEnvelopeAsync<TEvent>
    public async ValueTask PublishEnvelopeAsync<TEvent>(Envelopes.IEventEnvelope<TEvent> envelope, CancellationToken cancellationToken = default) where TEvent : IEvent

    Publishes an event wrapped in an envelope carrying ambient metadata to all registered subscribers asynchronously.

    envelope: Envelopes.IEventEnvelope<TEvent>
    The event envelope carrying payload and ambient metadata. Must not be `null`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous publish operation.

    Type parameters: TEvent: The concrete event type to publish. Must implement `IEvent`.

  • methodSubscribe<TEvent>
    public void Subscribe<TEvent>(IEnvelopeEventHandler<TEvent> handler) where TEvent : IEvent

    Registers a handler instance to receive events of the specified type.

    handler: IEnvelopeEventHandler<TEvent>
    The handler instance to register. Must not be `null`.

    Type parameters: TEvent: The event type to subscribe to. Exceptions: ArgumentNullException: `handler` is `null`

  • methodSubscribe<TEvent>
    public void Subscribe<TEvent>(IEventHandler<TEvent> handler) where TEvent : IEvent

    Registers a handler instance to receive events of the specified type.

    handler: IEventHandler<TEvent>
    The handler instance to register. Must not be `null`.

    Type parameters: TEvent: The event type to subscribe to. Exceptions: ArgumentNullException: `handler` is `null`

  • methodUnsubscribe<TEvent>
    public void Unsubscribe<TEvent>(IEnvelopeEventHandler<TEvent> handler) where TEvent : IEvent

    Removes a previously registered handler from receiving events of the specified type.

    handler: IEnvelopeEventHandler<TEvent>
    The handler instance to remove. Must not be `null`.

    Type parameters: TEvent: The event type to unsubscribe from. Exceptions: ArgumentNullException: `handler` is `null`

  • methodUnsubscribe<TEvent>
    public void Unsubscribe<TEvent>(IEventHandler<TEvent> handler) where TEvent : IEvent

    Removes a previously registered handler from receiving events of the specified type.

    handler: IEventHandler<TEvent>
    The handler instance to remove. Must not be `null`.

    Type parameters: TEvent: The event type to unsubscribe from. Exceptions: ArgumentNullException: `handler` is `null`

  • propertyMaxReentrancyDepth
    public int MaxReentrancyDepth { get; set; }

    Gets or sets the maximum allowable reentrancy depth before publication is aborted to prevent stack overflow. The default is 10.

    Exceptions: ArgumentOutOfRangeException: Value is less than or equal to zero

EricksonLopez.Events.Envelopes#

4
class

EventEnvelope

Assembly: EricksonLopez.Events
public static class EventEnvelope

Provides factory methods for constructing `EventEnvelope<TEvent>` instances.

Members (2)

  • methodCreate<TEvent>
    public static EventEnvelope<TEvent> Create<TEvent>(TEvent event, EventMetadata? metadata = null, EventType? type = null, EventVersion? version = null) where TEvent : IEvent

    Creates a new `EventEnvelope<TEvent>` wrapping the specified event.

    event: TEvent
    The event payload to wrap.
    metadata: EventMetadata?
    The optional ambient metadata.
    type: EventType?
    The optional explicit event type override.
    version: EventVersion?
    The optional explicit event version override.

    Returns: A new `EventEnvelope<TEvent>` instance.

    Type parameters: TEvent: The type of the event payload. Exceptions: ArgumentNullException: `event` is `null`

  • methodWrap<TEvent>
    public static EventEnvelope<TEvent> Wrap<TEvent>(TEvent event, CorrelationId? correlationId = null, CausationId? causationId = null, TenantId? tenantId = null, string? source = null) where TEvent : IEvent

    Creates a new `EventEnvelope<TEvent>` with explicit correlation, causation, and tenant identifiers.

    event: TEvent
    The event payload to wrap.
    correlationId: CorrelationId?
    The optional correlation identifier.
    causationId: CausationId?
    The optional causation identifier.
    tenantId: TenantId?
    The optional tenant identifier.
    source: string?
    The optional originating source identifier.

    Returns: A new `EventEnvelope<TEvent>` instance.

    Type parameters: TEvent: The type of the event payload. Exceptions: ArgumentNullException: `event` is `null`

record

EventEnvelope<TEvent>

Assembly: EricksonLopez.Events
public sealed record EventEnvelope<TEvent> : IEventEnvelope<TEvent> where TEvent : IEvent
Implements: IEventEnvelope<TEvent>

Represents an immutable envelope wrapping an event payload along with ambient metadata and transport headers.

Remarks:

Defaults are resolved at construction time: - If `id` is empty, the envelope inherits `IEvent.Id` from the payload. - If `type` is empty, the semantic event type is resolved from `Registry.StaticEventTypeRegistry`. - If `version` is the default, the schema version is resolved from `Registry.StaticEventTypeRegistry`. - If `occurredAt` is the default, the timestamp is inherited from the payload. Type parameters: TEvent: The type of the event payload.

Members (7)

  • constructorEventEnvelope
    public EventEnvelope(EventId id, EventType type, EventVersion version, DateTimeOffset occurredAt, TEvent payload, EventMetadata? metadata = null)

    Initializes a new instance of the `EventEnvelope<TEvent>` class with the specified payload and envelope metadata.

    id: EventId
    The unique identifier of the event.
    type: EventType
    The semantic event type.
    version: EventVersion
    The schema version of the event.
    occurredAt: DateTimeOffset
    The timestamp when the event occurred.
    payload: TEvent
    The event payload instance.
    metadata: EventMetadata?
    The optional ambient event metadata.

    Exceptions: ArgumentNullException: `payload` is `null`

  • propertyId
    public EventId Id { get; init; }

    Gets the unique identifier of the event.

  • propertyMetadata
    public EventMetadata Metadata { get; init; }

    Gets the ambient event metadata (correlation, causation, tenant, headers).

  • propertyOccurredAt
    public DateTimeOffset OccurredAt { get; init; }

    Gets the UTC timestamp when the event occurred.

  • propertyPayload
    public TEvent Payload { get; init; }

    Gets the strongly-typed event payload carried within this envelope.

  • propertyType
    public EventType Type { get; init; }

    Gets the semantic event type.

  • propertyVersion
    public EventVersion Version { get; init; }

    Gets the schema version of the event contract.

interface

IEventEnvelope

Assembly: EricksonLopez.Events.Contracts
public interface IEventEnvelope

Defines a non-generic abstraction for an event envelope carrying the event payload, ambient metadata, and transport headers.

Remarks:

Use this interface when the concrete event type is not known at compile time, such as during serialization or outbox dispatching. To access a strongly-typed payload, use `EventEnvelope<TEvent>` or cast the result of `GetPayload`.

Members (6)

  • methodGetPayload
    object GetPayload()

    Returns the untyped event payload for scenarios where the concrete event type is unknown at compile time.

    Returns: The event payload instance as `object`.

  • propertyId
    EventId Id { get; }

    Gets the unique identifier of the event.

  • propertyMetadata
    EventMetadata Metadata { get; }

    Gets the ambient event metadata (correlation, causation, tenant, headers).

  • propertyOccurredAt
    DateTimeOffset OccurredAt { get; }

    Gets the UTC timestamp when the event occurred.

  • propertyType
    EventType Type { get; }

    Gets the semantic event type.

  • propertyVersion
    EventVersion Version { get; }

    Gets the schema version of the event contract.

interface

IEventEnvelope<TEvent>

Assembly: EricksonLopez.Events.Contracts
public interface IEventEnvelope<TEvent> : IEventEnvelope where TEvent : Contracts.IEvent
Implements: IEventEnvelope

Defines a strongly-typed covariant abstraction for an event envelope carrying a specific event payload and ambient metadata.

Remarks:

Type parameters: TEvent: The type of the event payload.

Members (1)

  • propertyPayload
    TEvent Payload { get; }

    Gets the strongly-typed event payload carried within this envelope.

EricksonLopez.Events.Exceptions#

2
class

EventTypeNotFoundException

Assembly: EricksonLopez.Events
public sealed class EventTypeNotFoundException : Exception
Inherits: Exception

Represents errors that occur when an event type is not found in the registry.

Members (2)

  • constructorEventTypeNotFoundException
    public EventTypeNotFoundException(EventType eventType)

    Initializes a new instance of the `EventTypeNotFoundException` class for the specified event type.

    eventType: EventType
    The unresolved event type identifier.
  • propertyEventType
    public EventType EventType { get; }

    Gets the unresolved event type.

class

EventValidationException

Assembly: EricksonLopez.Events
public sealed class EventValidationException : Exception
Inherits: Exception

Represents errors that occur when an event type or payload fails validation rules.

Members (2)

  • constructorEventValidationException
    public EventValidationException(string message)

    Initializes a new instance of the `EventValidationException` class with a specified error message.

    message: string
    The message that describes the error.
  • constructorEventValidationException
    public EventValidationException(string message, Exception innerException)

    Initializes a new instance of the `EventValidationException` class with a specified error message and inner exception.

    message: string
    The message that describes the error.
    innerException: Exception
    The exception that is the cause of the current exception.

EricksonLopez.Events.Generators#

1
class

EventIncrementalGenerator

Assembly: EricksonLopez.Events.Generators
public sealed class EventIncrementalGenerator : IIncrementalGenerator
Implements: IIncrementalGenerator

Provides incremental source generation for discovering event types, handlers, and emitting compile-time registries.

Members (1)

  • methodInitialize
    public void Initialize(IncrementalGeneratorInitializationContext context)

    Inherits documentation from base type or interface.

    context: IncrementalGeneratorInitializationContext

EricksonLopez.Events.Generators.Analyzers#

3
class

DomainEventLeakAnalyzer

Assembly: EricksonLopez.Events.Generators
public sealed class DomainEventLeakAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Provides diagnostic analysis detecting domain events embedded directly in integration event contracts.

Members (3)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

  • fieldDiagnosticId
    public const string DiagnosticId

    Gets the diagnostic identifier for domain event leaks into integration events.

class

EventAttributeValidationAnalyzer

Assembly: EricksonLopez.Events.Generators
public sealed class EventAttributeValidationAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Provides diagnostic analysis validating event metadata attributes.

Members (5)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

  • fieldEmptyEventNameDiagnosticId
    public const string EmptyEventNameDiagnosticId

    Gets the diagnostic identifier for an empty event name.

  • fieldEmptyEventSourceDiagnosticId
    public const string EmptyEventSourceDiagnosticId

    Gets the diagnostic identifier for an empty event source.

  • fieldInvalidVersionDiagnosticId
    public const string InvalidVersionDiagnosticId

    Gets the diagnostic identifier for an invalid event version.

class

EventImmutabilityAnalyzer

Assembly: EricksonLopez.Events.Generators
public sealed class EventImmutabilityAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Provides diagnostic analysis enforcing immutability on types implementing event contracts.

Members (4)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

  • fieldDiagnosticId
    public const string DiagnosticId

    Gets the diagnostic identifier for mutable event properties.

  • fieldMutableCollectionDiagnosticId
    public const string MutableCollectionDiagnosticId

    Gets the diagnostic identifier for mutable collection properties in event types.

EricksonLopez.Events.Identifiers#

6
record

CausationId

Assembly: EricksonLopez.Events.Contracts
public readonly record struct CausationId : IComparable<CausationId>, IComparable, IEquatable<CausationId>, IParsable<CausationId>
Implements: IComparable, IComparable<CausationId>, IEquatable<CausationId>, IParsable<CausationId>

Represents a causation identifier pointing to the immediate direct trigger of an event.

Members (19)

  • constructorCausationId
    public CausationId(string value)

    Initializes a new instance of the `CausationId` struct.

    value: string
    The causation identifier string.
  • methodCompareTo
    public int CompareTo(CausationId other)

    Inherits documentation from base type or interface.

    other: CausationId
  • methodCompareTo
    public int CompareTo(object? obj)

    Inherits documentation from base type or interface.

    obj: object?
  • methodFrom
    public static CausationId From(EventId eventId)

    Creates a `CausationId` from an `EventId`.

    eventId: EventId
    The parent event id.

    Returns: A new `CausationId` instance.

  • methodFrom
    public static CausationId From(Guid identifier)

    Creates a `CausationId` from a unique identifier.

    identifier: Guid
    The unique identifier value.

    Returns: A new `CausationId` instance.

  • methodFrom
    public static CausationId From(string value)

    Creates a `CausationId` from a string value.

    value: string
    The string value.

    Returns: A new `CausationId` instance.

  • methodParse
    public static CausationId Parse(string s)

    Parses a string into a `CausationId`.

    s: string
    The string representation to parse.

    Returns: The parsed `CausationId`.

  • methodParse
    public static CausationId Parse(string s, IFormatProvider? provider)

    Inherits documentation from base type or interface.

    s: string
    provider: IFormatProvider?
  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodTryParse
    public static bool TryParse(string? s, IFormatProvider? provider, out CausationId result)

    Inherits documentation from base type or interface.

    s: string?
    provider: IFormatProvider?
    result: out CausationId
  • methodexplicit operator CausationId
    public static explicit operator CausationId(string value)

    Converts a string to a `CausationId` instance.

    value: string
    The string value to convert.

    Returns: A new `CausationId` initialized with the specified value.

  • methodimplicit operator string
    public static implicit operator string(CausationId id)

    Converts a `CausationId` to its underlying string value.

    id: CausationId
    The causation identifier to convert.

    Returns: The string representation of the causation identifier.

  • methodoperator <
    public static bool operator <(CausationId left, CausationId right)

    Determines whether a specified `CausationId` is less than another specified `CausationId`.

    left: CausationId
    The first causation identifier to compare.
    right: CausationId
    The second causation identifier to compare.

    Returns: `true` if `left` is less than `right`; otherwise, `false`.

  • methodoperator <=
    public static bool operator <=(CausationId left, CausationId right)

    Determines whether a specified `CausationId` is less than or equal to another specified `CausationId`.

    left: CausationId
    The first causation identifier to compare.
    right: CausationId
    The second causation identifier to compare.

    Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.

  • methodoperator >
    public static bool operator >(CausationId left, CausationId right)

    Determines whether a specified `CausationId` is greater than another specified `CausationId`.

    left: CausationId
    The first causation identifier to compare.
    right: CausationId
    The second causation identifier to compare.

    Returns: `true` if `left` is greater than `right`; otherwise, `false`.

  • methodoperator >=
    public static bool operator >=(CausationId left, CausationId right)

    Determines whether a specified `CausationId` is greater than or equal to another specified `CausationId`.

    left: CausationId
    The first causation identifier to compare.
    right: CausationId
    The second causation identifier to compare.

    Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.

  • propertyIsEmpty
    public bool IsEmpty { get; }

    Gets a value indicating whether the causation id is empty.

  • propertyValue
    public string Value { get; }

    Gets the string representation of the causation id.

  • fieldEmpty
    public static readonly CausationId Empty

    Gets the empty `CausationId` instance.

record

CorrelationId

Assembly: EricksonLopez.Events.Contracts
public readonly record struct CorrelationId : IComparable<CorrelationId>, IComparable, IEquatable<CorrelationId>, IParsable<CorrelationId>
Implements: IComparable, IComparable<CorrelationId>, IEquatable<CorrelationId>, IParsable<CorrelationId>

Represents a distributed event correlation identifier that traces a business workflow across asynchronous event streams.

Remarks:

Architectural Boundary & Semantic Scope: This struct models the strongly-typed correlation identity carried within event envelopes to correlate events across distributed processes, sagas, and outbox handlers. For in-memory diagnostic error correlation, `EricksonLopez.Result.Error` carries a lightweight string-based correlation property, keeping the error model decoupled from event contracts.

Members (19)

  • constructorCorrelationId
    public CorrelationId(string value)

    Initializes a new instance of the `CorrelationId` struct.

    value: string
    The correlation identifier string.
  • methodCompareTo
    public int CompareTo(CorrelationId other)

    Inherits documentation from base type or interface.

    other: CorrelationId
  • methodCompareTo
    public int CompareTo(object? obj)

    Inherits documentation from base type or interface.

    obj: object?
  • methodFrom
    public static CorrelationId From(Guid value)

    Creates a `CorrelationId` from a GUID.

    value: Guid
    The GUID value.

    Returns: A new `CorrelationId` instance.

  • methodFrom
    public static CorrelationId From(string value)

    Creates a `CorrelationId` from a string value.

    value: string
    The string value.

    Returns: A new `CorrelationId` instance.

  • methodNew
    public static CorrelationId New()

    Generates a new unique `CorrelationId` using native time-ordered GUID Version 7 on .NET 9+, falling back to a cryptographically random GUID Version 4 (`Guid.NewGuid`) on .NET 8.

    Returns: A new `CorrelationId` instance initialized with a unique identifier.

  • methodParse
    public static CorrelationId Parse(string s)

    Parses a string into a `CorrelationId`.

    s: string
    The string representation to parse.

    Returns: The parsed `CorrelationId`.

  • methodParse
    public static CorrelationId Parse(string s, IFormatProvider? provider)

    Inherits documentation from base type or interface.

    s: string
    provider: IFormatProvider?
  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodTryParse
    public static bool TryParse(string? s, IFormatProvider? provider, out CorrelationId result)

    Inherits documentation from base type or interface.

    s: string?
    provider: IFormatProvider?
    result: out CorrelationId
  • methodexplicit operator CorrelationId
    public static explicit operator CorrelationId(string value)

    Converts a string to a `CorrelationId` instance.

    value: string
    The string value.

    Returns: A new `CorrelationId` initialized with the specified value.

  • methodimplicit operator string
    public static implicit operator string(CorrelationId id)

    Converts a `CorrelationId` to its underlying string value.

    id: CorrelationId
    The correlation identifier to convert.

    Returns: The string representation of the correlation identifier.

  • methodoperator <
    public static bool operator <(CorrelationId left, CorrelationId right)

    Determines whether a specified `CorrelationId` is less than another specified `CorrelationId`.

    left: CorrelationId
    The first correlation identifier to compare.
    right: CorrelationId
    The second correlation identifier to compare.

    Returns: `true` if `left` is less than `right`; otherwise, `false`.

  • methodoperator <=
    public static bool operator <=(CorrelationId left, CorrelationId right)

    Determines whether a specified `CorrelationId` is less than or equal to another specified `CorrelationId`.

    left: CorrelationId
    The first correlation identifier to compare.
    right: CorrelationId
    The second correlation identifier to compare.

    Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.

  • methodoperator >
    public static bool operator >(CorrelationId left, CorrelationId right)

    Determines whether a specified `CorrelationId` is greater than another specified `CorrelationId`.

    left: CorrelationId
    The first correlation identifier to compare.
    right: CorrelationId
    The second correlation identifier to compare.

    Returns: `true` if `left` is greater than `right`; otherwise, `false`.

  • methodoperator >=
    public static bool operator >=(CorrelationId left, CorrelationId right)

    Determines whether a specified `CorrelationId` is greater than or equal to another specified `CorrelationId`.

    left: CorrelationId
    The first correlation identifier to compare.
    right: CorrelationId
    The second correlation identifier to compare.

    Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.

  • propertyIsEmpty
    public bool IsEmpty { get; }

    Gets a value indicating whether the correlation id is empty.

  • propertyValue
    public string Value { get; }

    Gets the string representation of the correlation id.

  • fieldEmpty
    public static readonly CorrelationId Empty

    Gets the empty `CorrelationId` instance.

record

EventId

Assembly: EricksonLopez.Events.Contracts
public readonly record struct EventId : IComparable<EventId>, IComparable, IEquatable<EventId>, ISpanFormattable, IUtf8SpanFormattable, ISpanParsable<EventId>
Implements: IComparable, IComparable<EventId>, IEquatable<EventId>, ISpanFormattable, ISpanParsable<EventId>, IUtf8SpanFormattable

Represents a strongly typed, unique identifier for an event (time-sortable GUID Version 7 on .NET 9+, or random GUID Version 4 on .NET 8).

Members (24)

  • constructorEventId
    public EventId(Guid value)

    Initializes a new instance of the `EventId` struct with a specific `Guid`.

    value: Guid
    The underlying unique identifier value.
  • methodCompareTo
    public int CompareTo(EventId other)

    Inherits documentation from base type or interface.

    other: EventId
  • methodCompareTo
    public int CompareTo(object? obj)

    Inherits documentation from base type or interface.

    obj: object?
  • methodFrom
    public static EventId From(Guid value)

    Creates an `EventId` from an existing `Guid`.

    value: Guid
    The GUID value.

    Returns: A new `EventId` instance.

  • methodNew
    public static EventId New()

    Creates a new `EventId` using native time-ordered GUID Version 7 on .NET 9+, falling back to a cryptographically random GUID Version 4 (`Guid.NewGuid`) on .NET 8.

    Returns: A new `EventId` instance.

  • methodParse
    public static EventId Parse(ReadOnlySpan<char> s)

    Parses a character span into an `EventId`.

    s: ReadOnlySpan<char>
    The span representation to parse.

    Returns: The parsed `EventId`.

  • methodParse
    public static EventId Parse(ReadOnlySpan<char> s, IFormatProvider? provider)

    Inherits documentation from base type or interface.

    s: ReadOnlySpan<char>
    provider: IFormatProvider?
  • methodParse
    public static EventId Parse(string s)

    Parses a string into an `EventId`.

    s: string
    The string representation to parse.

    Returns: The parsed `EventId`.

  • methodParse
    public static EventId Parse(string s, IFormatProvider? provider)

    Inherits documentation from base type or interface.

    s: string
    provider: IFormatProvider?
  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodToString
    public string ToString(string? format, IFormatProvider? formatProvider)

    Inherits documentation from base type or interface.

    format: string?
    formatProvider: IFormatProvider?
  • methodTryFormat
    public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)

    Inherits documentation from base type or interface.

    utf8Destination: Span<byte>
    bytesWritten: out int
    format: ReadOnlySpan<char>
    provider: IFormatProvider?
  • methodTryFormat
    public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)

    Inherits documentation from base type or interface.

    destination: Span<char>
    charsWritten: out int
    format: ReadOnlySpan<char>
    provider: IFormatProvider?
  • methodTryParse
    public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out EventId result)

    Inherits documentation from base type or interface.

    s: ReadOnlySpan<char>
    provider: IFormatProvider?
    result: out EventId
  • methodTryParse
    public static bool TryParse(string? s, IFormatProvider? provider, out EventId result)

    Inherits documentation from base type or interface.

    s: string?
    provider: IFormatProvider?
    result: out EventId
  • methodexplicit operator EventId
    public static explicit operator EventId(Guid identifier)

    Converts a `Guid` to an `EventId`.

    identifier: Guid
    The unique identifier value.

    Returns: A new `EventId` initialized with the specified value.

  • methodimplicit operator Guid
    public static implicit operator Guid(EventId id)

    Converts an `EventId` to its underlying `Guid`.

    id: EventId
    The event identifier to convert.

    Returns: The underlying `Guid` value.

  • methodoperator <
    public static bool operator <(EventId left, EventId right)

    Determines whether a specified `EventId` is less than another specified `EventId`.

    left: EventId
    The first event identifier to compare.
    right: EventId
    The second event identifier to compare.

    Returns: `true` if `left` is less than `right`; otherwise, `false`.

  • methodoperator <=
    public static bool operator <=(EventId left, EventId right)

    Determines whether a specified `EventId` is less than or equal to another specified `EventId`.

    left: EventId
    The first event identifier to compare.
    right: EventId
    The second event identifier to compare.

    Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.

  • methodoperator >
    public static bool operator >(EventId left, EventId right)

    Determines whether a specified `EventId` is greater than another specified `EventId`.

    left: EventId
    The first event identifier to compare.
    right: EventId
    The second event identifier to compare.

    Returns: `true` if `left` is greater than `right`; otherwise, `false`.

  • methodoperator >=
    public static bool operator >=(EventId left, EventId right)

    Determines whether a specified `EventId` is greater than or equal to another specified `EventId`.

    left: EventId
    The first event identifier to compare.
    right: EventId
    The second event identifier to compare.

    Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.

  • propertyIsEmpty
    public bool IsEmpty { get; }

    Gets a value indicating whether this instance is empty.

  • propertyValue
    public Guid Value { get; }

    Gets the underlying `Guid` value.

  • fieldEmpty
    public static readonly EventId Empty

    Gets the empty `EventId` instance.

record

EventType

Assembly: EricksonLopez.Events.Contracts
public readonly record struct EventType : IComparable<EventType>, IComparable, IEquatable<EventType>, IParsable<EventType>
Implements: IComparable, IComparable<EventType>, IEquatable<EventType>, IParsable<EventType>

Represents the semantic identity of an event type, independent of CLR type or namespace names.

Members (17)

  • constructorEventType
    public EventType(string value)

    Initializes a new instance of the `EventType` struct.

    value: string
    The event type name.

    Exceptions: ArgumentException: `value` is `null`, empty, or consists only of white-space characters

  • methodCompareTo
    public int CompareTo(EventType other)

    Inherits documentation from base type or interface.

    other: EventType
  • methodCompareTo
    public int CompareTo(object? obj)

    Inherits documentation from base type or interface.

    obj: object?
  • methodEquals
    public bool Equals(EventType other)

    Inherits documentation from base type or interface.

    other: EventType
  • methodFrom
    public static EventType From(string value)

    Creates a new `EventType` from a string value.

    value: string
    The event type string.

    Returns: A new `EventType` instance.

  • methodGetHashCode
    public override int GetHashCode()

    Inherits documentation from base type or interface.

  • methodParse
    public static EventType Parse(string s, IFormatProvider? provider = null)

    Inherits documentation from base type or interface.

    s: string
    provider: IFormatProvider?
  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodTryParse
    public static bool TryParse(string? s, IFormatProvider? provider, out EventType result)

    Inherits documentation from base type or interface.

    s: string?
    provider: IFormatProvider?
    result: out EventType
  • methodexplicit operator EventType
    public static explicit operator EventType(string value)

    Converts a `string` to an `EventType` instance.

    value: string
    The string value to convert.

    Returns: A new `EventType` initialized with the specified value.

  • methodimplicit operator string
    public static implicit operator string(EventType type)

    Converts an `EventType` to its underlying `string` value.

    type: EventType
    The event type to convert.

    Returns: The string representation of the event type.

  • methodoperator <
    public static bool operator <(EventType left, EventType right)

    Determines whether a specified `EventType` is less than another specified `EventType`.

    left: EventType
    The first event type to compare.
    right: EventType
    The second event type to compare.

    Returns: `true` if `left` is less than `right`; otherwise, `false`.

  • methodoperator <=
    public static bool operator <=(EventType left, EventType right)

    Determines whether a specified `EventType` is less than or equal to another specified `EventType`.

    left: EventType
    The first event type to compare.
    right: EventType
    The second event type to compare.

    Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.

  • methodoperator >
    public static bool operator >(EventType left, EventType right)

    Determines whether a specified `EventType` is greater than another specified `EventType`.

    left: EventType
    The first event type to compare.
    right: EventType
    The second event type to compare.

    Returns: `true` if `left` is greater than `right`; otherwise, `false`.

  • methodoperator >=
    public static bool operator >=(EventType left, EventType right)

    Determines whether a specified `EventType` is greater than or equal to another specified `EventType`.

    left: EventType
    The first event type to compare.
    right: EventType
    The second event type to compare.

    Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.

  • propertyIsEmpty
    public bool IsEmpty { get; }

    Gets a value indicating whether the event type is empty or uninitialized.

  • propertyValue
    public string Value { get; }

    Gets the string representation of the event type.

record

EventVersion

Assembly: EricksonLopez.Events.Contracts
public readonly record struct EventVersion : IComparable<EventVersion>, IComparable, IEquatable<EventVersion>, IParsable<EventVersion>
Implements: IComparable, IComparable<EventVersion>, IEquatable<EventVersion>, IParsable<EventVersion>

Represents a monotonic version for an event contract schema.

Members (20)

  • constructorEventVersion
    public EventVersion(uint value)

    Initializes a new instance of the `EventVersion` struct.

    value: uint
    The version number (must be greater than or equal to 1).

    Exceptions: ArgumentOutOfRangeException: `value` is equal to zero

  • methodCompareTo
    public int CompareTo(EventVersion other)

    Inherits documentation from base type or interface.

    other: EventVersion
  • methodCompareTo
    public int CompareTo(object? obj)

    Inherits documentation from base type or interface.

    obj: object?
  • methodEquals
    public bool Equals(EventVersion other)

    Inherits documentation from base type or interface.

    other: EventVersion
  • methodFrom
    public static EventVersion From(int value)

    Creates an `EventVersion` from a standard signed integer.

    value: int
    The version number.

    Returns: A new `EventVersion` instance.

    Exceptions: ArgumentOutOfRangeException: `value` is less than or equal to zero

  • methodFrom
    public static EventVersion From(uint value)

    Creates an `EventVersion` from an unsigned integer.

    value: uint
    The version number.

    Returns: A new `EventVersion` instance.

  • methodGetHashCode
    public override int GetHashCode()

    Inherits documentation from base type or interface.

  • methodParse
    public static EventVersion Parse(string s)

    Parses a string into an `EventVersion`.

    s: string
    The string representation to parse.

    Returns: The parsed `EventVersion`.

  • methodParse
    public static EventVersion Parse(string s, IFormatProvider? provider)

    Inherits documentation from base type or interface.

    s: string
    provider: IFormatProvider?
  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodTryParse
    public static bool TryParse(string? s, IFormatProvider? provider, out EventVersion result)

    Inherits documentation from base type or interface.

    s: string?
    provider: IFormatProvider?
    result: out EventVersion
  • methodexplicit operator EventVersion
    public static explicit operator EventVersion(uint value)

    Converts a `uint` to an `EventVersion`.

    value: uint
    The unsigned integer value to convert.

    Returns: A new `EventVersion` initialized with the specified value.

  • methodimplicit operator uint
    public static implicit operator uint(EventVersion version)

    Converts an `EventVersion` to its underlying `uint` value.

    version: EventVersion
    The version to convert.

    Returns: The underlying numeric version value.

  • methodoperator <
    public static bool operator <(EventVersion left, EventVersion right)

    Determines whether a specified `EventVersion` is less than another specified `EventVersion`.

    left: EventVersion
    The first event version to compare.
    right: EventVersion
    The second event version to compare.

    Returns: `true` if `left` is less than `right`; otherwise, `false`.

  • methodoperator <=
    public static bool operator <=(EventVersion left, EventVersion right)

    Determines whether a specified `EventVersion` is less than or equal to another specified `EventVersion`.

    left: EventVersion
    The first event version to compare.
    right: EventVersion
    The second event version to compare.

    Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.

  • methodoperator >
    public static bool operator >(EventVersion left, EventVersion right)

    Determines whether a specified `EventVersion` is greater than another specified `EventVersion`.

    left: EventVersion
    The first event version to compare.
    right: EventVersion
    The second event version to compare.

    Returns: `true` if `left` is greater than `right`; otherwise, `false`.

  • methodoperator >=
    public static bool operator >=(EventVersion left, EventVersion right)

    Determines whether a specified `EventVersion` is greater than or equal to another specified `EventVersion`.

    left: EventVersion
    The first event version to compare.
    right: EventVersion
    The second event version to compare.

    Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.

  • propertyIsUninitialized
    public bool IsUninitialized { get; }

    Gets a value indicating whether this version instance is uninitialized (default struct state).

  • propertyValue
    public uint Value { get; }

    Gets the unsigned integer value of the version.

  • fieldV1
    public static readonly EventVersion V1

    Gets the default initial version (V1).

record

TenantId

Assembly: EricksonLopez.Events.Contracts
public readonly record struct TenantId : IComparable<TenantId>, IComparable, IEquatable<TenantId>, IParsable<TenantId>
Implements: IComparable, IComparable<TenantId>, IEquatable<TenantId>, IParsable<TenantId>

Represents an event correlation and routing tenant identifier attached to an event envelope.

Remarks:

Architectural Boundary & Semantic Scope: This struct models the tenant identity carried within event envelopes for distributed event routing, partition key generation, and event correlation in multi-tenant event streams. It is intentionally distinct from the tenant resolution and lifecycle identity managed by `EricksonLopez.MultiTenancy`. Events remain decoupled from tenancy resolution engines.

Members (21)

  • constructorTenantId
    public TenantId(string value)

    Initializes a new instance of the `TenantId` struct.

    value: string
    The tenant identifier string.
  • methodCompareTo
    public int CompareTo(object? obj)

    Inherits documentation from base type or interface.

    obj: object?
  • methodCompareTo
    public int CompareTo(TenantId other)

    Inherits documentation from base type or interface.

    other: TenantId
  • methodEquals
    public bool Equals(TenantId other)

    Inherits documentation from base type or interface.

    other: TenantId
  • methodFrom
    public static TenantId From(Guid value)

    Creates a `TenantId` from a `Guid`, interoperable with EricksonLopez.MultiTenancy.

    value: Guid
    The tenant GUID.

    Returns: A new `TenantId` formatted as a standard 36-character hyphenated UUID.

  • methodFrom
    public static TenantId From(string value)

    Creates a `TenantId` from a string value.

    value: string
    The string value.

    Returns: A new `TenantId` instance.

  • methodGetHashCode
    public override int GetHashCode()

    Inherits documentation from base type or interface.

  • methodParse
    public static TenantId Parse(string s, IFormatProvider? provider = null)

    Inherits documentation from base type or interface.

    s: string
    provider: IFormatProvider?
  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodTryParse
    public static bool TryParse(string? s, IFormatProvider? provider, out TenantId result)

    Inherits documentation from base type or interface.

    s: string?
    provider: IFormatProvider?
    result: out TenantId
  • methodTryToGuid
    public bool TryToGuid(out Guid tenantGuid)

    Attempts to parse the underlying value as a `Guid` for interoperability with EricksonLopez.MultiTenancy.

    tenantGuid: out Guid
    When this method returns, contains the parsed GUID value if successful; otherwise, `Guid.Empty`.

    Returns: `true` if the value is a valid GUID; otherwise, `false`.

  • methodexplicit operator TenantId
    public static explicit operator TenantId(Guid value)

    Converts a `Guid` to a `TenantId` instance.

    value: Guid
    The GUID value to convert.

    Returns: A new `TenantId` initialized with the GUID string.

  • methodexplicit operator TenantId
    public static explicit operator TenantId(string value)

    Converts a string to a `TenantId` instance.

    value: string
    The string value to convert.

    Returns: A new `TenantId` initialized with the specified value.

  • methodimplicit operator string
    public static implicit operator string(TenantId id)

    Converts a `TenantId` to its underlying string value.

    id: TenantId
    The tenant identifier to convert.

    Returns: The string representation of the tenant identifier.

  • methodoperator <
    public static bool operator <(TenantId left, TenantId right)

    Determines whether a specified `TenantId` is less than another specified `TenantId`.

    left: TenantId
    The first tenant identifier to compare.
    right: TenantId
    The second tenant identifier to compare.

    Returns: `true` if `left` is less than `right`; otherwise, `false`.

  • methodoperator <=
    public static bool operator <=(TenantId left, TenantId right)

    Determines whether a specified `TenantId` is less than or equal to another specified `TenantId`.

    left: TenantId
    The first tenant identifier to compare.
    right: TenantId
    The second tenant identifier to compare.

    Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.

  • methodoperator >
    public static bool operator >(TenantId left, TenantId right)

    Determines whether a specified `TenantId` is greater than another specified `TenantId`.

    left: TenantId
    The first tenant identifier to compare.
    right: TenantId
    The second tenant identifier to compare.

    Returns: `true` if `left` is greater than `right`; otherwise, `false`.

  • methodoperator >=
    public static bool operator >=(TenantId left, TenantId right)

    Determines whether a specified `TenantId` is greater than or equal to another specified `TenantId`.

    left: TenantId
    The first tenant identifier to compare.
    right: TenantId
    The second tenant identifier to compare.

    Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.

  • propertyIsEmpty
    public bool IsEmpty { get; }

    Gets a value indicating whether the tenant id is empty.

  • propertyValue
    public string Value { get; }

    Gets the string representation of the tenant id.

  • fieldEmpty
    public static readonly TenantId Empty

    Gets the empty `TenantId` instance.

EricksonLopez.Events.Metadata#

2
record

EventMetadata

Assembly: EricksonLopez.Events.Contracts
public sealed record EventMetadata

Represents strongly-typed, immutable ambient metadata accompanying an event across system boundaries.

Remarks:

`EventMetadata` is immutable. All mutation operations (e.g., `WithHeader`) return a new instance. The `CustomHeaders` collection is never `null` and is case-insensitive. To construct instances fluently, use `EventMetadataBuilder`.

Members (13)

  • constructorEventMetadata
    public EventMetadata(CorrelationId correlationId, CausationId causationId, TenantId tenantId, string? source = null, string? contentType = null, IReadOnlyDictionary<string, string>? customHeaders = null)

    Initializes a new instance of the `EventMetadata` class with the specified metadata values.

    correlationId: CorrelationId
    The correlation identifier tracing the workflow.
    causationId: CausationId
    The causation identifier representing the direct trigger.
    tenantId: TenantId
    The tenant identifier for multi-tenant isolation.
    source: string?
    The optional originating source or service name.
    contentType: string?
    The optional payload content type.
    customHeaders: IReadOnlyDictionary<string, string>?
    The optional collection of custom headers.
  • methodCreate
    public static EventMetadata Create(CorrelationId? correlationId = null, CausationId? causationId = null, TenantId? tenantId = null, string? source = null, string? contentType = null, IReadOnlyDictionary<string, string>? customHeaders = null)

    Creates a new `EventMetadata` instance with specified values.

    correlationId: CorrelationId?
    The optional correlation identifier.
    causationId: CausationId?
    The optional causation identifier.
    tenantId: TenantId?
    The optional tenant identifier.
    source: string?
    The optional originating source.
    contentType: string?
    The optional payload content type.
    customHeaders: IReadOnlyDictionary<string, string>?
    The optional collection of custom headers.

    Returns: A new `EventMetadata` instance with empty default identifiers for any omitted parameters.

  • methodEquals
    public bool Equals(EventMetadata? other)

    Inherits documentation from base type or interface.

    other: EventMetadata?
  • methodGetHashCode
    public override int GetHashCode()

    Inherits documentation from base type or interface.

  • methodTryGetHeader
    public bool TryGetHeader(string key, out string? value)

    Attempts to retrieve a custom header value by its key.

    key: string
    The header key.
    value: out string?
    When this method returns, contains the retrieved header value if found; otherwise, `null`.

    Returns: `true` if the header was found; otherwise, `false`.

    The lookup is case-insensitive because `CustomHeaders` is always constructed with `StringComparer.OrdinalIgnoreCase`. A single `TryGetValue` call is sufficient — no secondary linear scan is needed (EVT-MED-META-001 fix).

  • methodWithHeader
    public EventMetadata WithHeader(string key, string value)

    Returns a new `EventMetadata` instance with the specified header added or replaced.

    key: string
    The header key.
    value: string
    The header value.

    Returns: A new `EventMetadata` with the updated header.

    Exceptions: ArgumentException: `key` is `null`, empty, or consists only of white-space characters

  • propertyCausationId
    public CausationId CausationId { get; init; }

    Gets the causation identifier representing the direct trigger of this event.

  • propertyContentType
    public string? ContentType { get; init; }

    Gets the MIME content type of the event payload (e.g., `application/json`).

  • propertyCorrelationId
    public CorrelationId CorrelationId { get; init; }

    Gets the correlation identifier tracing the end-to-end business workflow.

  • propertyCustomHeaders
    public IReadOnlyDictionary<string, string> CustomHeaders { get; init; }

    Gets the case-insensitive, read-only collection of custom transport headers or extension attributes.

    Never `null`. Returns an empty collection when no custom headers are set.

  • propertySource
    public string? Source { get; init; }

    Gets the originating source or service that emitted the event.

  • propertyTenantId
    public TenantId TenantId { get; init; }

    Gets the optional tenant identifier for multi-tenant isolation.

  • fieldEmpty
    public static readonly EventMetadata Empty

    Gets the empty default `EventMetadata` instance.

class

EventMetadataBuilder

Assembly: EricksonLopez.Events.Contracts
public sealed class EventMetadataBuilder

Provides a fluent builder for creating immutable `EventMetadata` instances.

Members (10)

  • methodBuild
    public EventMetadata Build()

    Builds and returns the configured immutable `EventMetadata` instance.

    Returns: A new immutable `EventMetadata` instance containing all configured values.

  • methodWithCausationId
    public EventMetadataBuilder WithCausationId(CausationId causationId)

    Configures the causation identifier representing the direct trigger of the event.

    causationId: CausationId
    The causation identifier of the event that caused the current event.

    Returns: The current builder instance to support method chaining.

  • methodWithCausationId
    public EventMetadataBuilder WithCausationId(string causationId)

    Configures the causation identifier for the event metadata from a string value.

    causationId: string
    The causation identifier string.

    Returns: The current builder instance to support method chaining.

  • methodWithContentType
    public EventMetadataBuilder WithContentType(string? contentType)

    Configures the MIME content type of the event payload.

    contentType: string?
    The MIME content type string (e.g., `application/json`).

    Returns: The current builder instance to support method chaining.

  • methodWithCorrelationId
    public EventMetadataBuilder WithCorrelationId(CorrelationId correlationId)

    Configures the correlation identifier for the event metadata.

    correlationId: CorrelationId
    The correlation identifier tracing the end-to-end business workflow.

    Returns: The current builder instance to support method chaining.

  • methodWithCorrelationId
    public EventMetadataBuilder WithCorrelationId(string correlationId)

    Configures the correlation identifier for the event metadata from a string value.

    correlationId: string
    The correlation identifier string.

    Returns: The current builder instance to support method chaining.

  • methodWithHeader
    public EventMetadataBuilder WithHeader(string key, string value)

    Adds or replaces a custom header entry in the event metadata.

    key: string
    The header key. Must not be `null`, empty, or whitespace.
    value: string
    The header value.

    Returns: The current builder instance to support method chaining.

    Exceptions: ArgumentException: `key` is `null`, empty, or consists only of white-space characters

  • methodWithSource
    public EventMetadataBuilder WithSource(string? source)

    Configures the originating source of the event.

    source: string?
    The source identifier or URI string (e.g., a service name or absolute URI).

    Returns: The current builder instance to support method chaining.

  • methodWithTenantId
    public EventMetadataBuilder WithTenantId(string tenantId)

    Configures the tenant identifier for the event metadata from a string value.

    tenantId: string
    The tenant identifier string.

    Returns: The current builder instance to support method chaining.

  • methodWithTenantId
    public EventMetadataBuilder WithTenantId(TenantId tenantId)

    Configures the tenant identifier for multi-tenant event routing and isolation.

    tenantId: TenantId
    The tenant identifier to associate with the event.

    Returns: The current builder instance to support method chaining.

EricksonLopez.Events.OpenTelemetry#

1
class

EventsOpenTelemetryExtensions

Assembly: EricksonLopez.Events.OpenTelemetry
public static class EventsOpenTelemetryExtensions

Provides extension methods for registering event instrumentation with OpenTelemetry.

Members (2)

  • methodAddEventsInstrumentation
    public static MeterProviderBuilder AddEventsInstrumentation(this MeterProviderBuilder builder)

    Adds event metrics instrumentation to the meter provider.

    builder: this MeterProviderBuilder
    The `MeterProviderBuilder` to configure.

    Returns: The configured `MeterProviderBuilder` instance.

    Exceptions: ArgumentNullException: `builder` is `null`

  • methodAddEventsInstrumentation
    public static TracerProviderBuilder AddEventsInstrumentation(this TracerProviderBuilder builder)

    Adds event distributed tracing instrumentation to the tracer provider.

    builder: this TracerProviderBuilder
    The `TracerProviderBuilder` to configure.

    Returns: The configured `TracerProviderBuilder` instance.

    Exceptions: ArgumentNullException: `builder` is `null`

EricksonLopez.Events.Registry#

5
record

EventTypeDescriptor

Assembly: EricksonLopez.Events
public sealed record EventTypeDescriptor(Type ClrType, EventType EventType, EventVersion Version, string? Source)

Represents metadata describing a registered event type.

Members (6)

  • constructorEventTypeDescriptor
    public EventTypeDescriptor(Type ClrType, EventType EventType, EventVersion Version, string? Source = null)

    Initializes a new instance of EventTypeDescriptor.

    ClrType: Type
    The CLR `Type` of the event.
    EventType: EventType
    The strongly-typed semantic event type.
    Version: EventVersion
    The schema contract version.
    Source: string?
    The optional default producer source URI or identifier.
  • methodFor<TEvent>
    public static EventTypeDescriptor For<TEvent>(EventType eventType, EventVersion? version = null, string? source = null)

    Creates an `EventTypeDescriptor` for the specified event type.

    eventType: EventType
    The semantic event type.
    version: EventVersion?
    The optional contract version. Defaults to `EventVersion.V1`.
    source: string?
    The optional event producer source.

    Returns: A new `EventTypeDescriptor` instance.

    Type parameters: TEvent: The type of the event.

  • propertyClrType
    public Type ClrType { get; init; }

    The CLR `Type` of the event.

  • propertyEventType
    public EventType EventType { get; init; }

    The strongly-typed semantic event type.

  • propertySource
    public string? Source { get; init; }

    The optional default producer source URI or identifier.

  • propertyVersion
    public EventVersion Version { get; init; }

    The schema contract version.

class

EventTypeRegistry

Assembly: EricksonLopez.Events
public sealed class EventTypeRegistry : IEventTypeRegistry
Implements: IEventTypeRegistry

Provides an immutable registry for resolving event type descriptors.

Members (8)

  • constructorEventTypeRegistry
    public EventTypeRegistry(IEnumerable<EventTypeDescriptor> descriptors)

    Initializes a new instance of the `EventTypeRegistry` class with the specified descriptors.

    descriptors: IEnumerable<EventTypeDescriptor>
    The collection of descriptors to register.

    Exceptions: ArgumentNullException: `descriptors` is `null`

  • methodCreateBuilder
    public static EventTypeRegistryBuilder CreateBuilder()

    Creates a builder for constructing a new `EventTypeRegistry`.

    Returns: A new `EventTypeRegistryBuilder` instance.

  • methodGetAllDescriptors
    public IReadOnlyCollection<EventTypeDescriptor> GetAllDescriptors()

    Retrieves all registered event type descriptors.

    Returns: A read-only collection containing all registered `EventTypeDescriptor` instances.

  • methodTryGetDescriptor
    public bool TryGetDescriptor(EventType eventType, out EventTypeDescriptor? descriptor)

    Attempts to retrieve the descriptor associated with the specified semantic event type.

    eventType: EventType
    The semantic event type identifier.
    descriptor: out EventTypeDescriptor?
    When this method returns, contains the descriptor if found; otherwise, `null`.

    Returns: `true` if the descriptor was found; otherwise, `false`.

  • methodTryGetDescriptor
    public bool TryGetDescriptor(EventType eventType, EventVersion version, out EventTypeDescriptor? descriptor)

    Attempts to retrieve the descriptor associated with the specified semantic event type and contract schema version.

    eventType: EventType
    The semantic event type identifier.
    version: EventVersion
    The schema contract version.
    descriptor: out EventTypeDescriptor?
    When this method returns, contains the descriptor if found; otherwise, `null`.

    Returns: `true` if the descriptor was found; otherwise, `false`.

  • methodTryGetDescriptor
    public bool TryGetDescriptor(Type clrType, out EventTypeDescriptor? descriptor)

    Attempts to retrieve the descriptor associated with the specified semantic event type.

    clrType: Type
    descriptor: out EventTypeDescriptor?
    When this method returns, contains the descriptor if found; otherwise, `null`.

    Returns: `true` if the descriptor was found; otherwise, `false`.

  • methodTryGetDescriptor<TEvent>
    public bool TryGetDescriptor<TEvent>(out EventTypeDescriptor? descriptor) where TEvent : IEvent

    Attempts to retrieve the descriptor associated with the generic event type.

    descriptor: out EventTypeDescriptor?
    When this method returns, contains the descriptor if found; otherwise, `null`.

    Returns: `true` if the descriptor was found; otherwise, `false`.

    Type parameters: TEvent: The type of the event.

  • fieldEmpty
    public static readonly EventTypeRegistry Empty

    Gets the empty default registry instance.

class

EventTypeRegistryBuilder

Assembly: EricksonLopez.Events
public sealed class EventTypeRegistryBuilder

Provides a builder for constructing immutable `EventTypeRegistry` instances.

Members (3)

  • methodBuild
    public EventTypeRegistry Build()

    Builds and returns the immutable `EventTypeRegistry` containing all registered descriptors.

    Returns: A new `EventTypeRegistry` containing all registered descriptors.

  • methodRegister
    public EventTypeRegistryBuilder Register(EventTypeDescriptor descriptor)

    Registers an existing event type descriptor in the builder.

    descriptor: EventTypeDescriptor
    The descriptor to register.

    Returns: The current builder instance to support method chaining.

    Exceptions: ArgumentNullException: `descriptor` is `null`

  • methodRegister<TEvent>
    public EventTypeRegistryBuilder Register<TEvent>(string eventTypeName, uint version = 1, string? source = null) where TEvent : IEvent

    Registers an event type with the specified semantic name, version, and source.

    eventTypeName: string
    The semantic event type name (e.g., `orders.order-created`).
    version: uint
    The schema version number. Must be greater than or equal to 1. The default is 1.
    source: string?
    The optional originating source identifier or URI.

    Returns: The current builder instance to support method chaining.

    Type parameters: TEvent: The CLR type of the event to register. Must implement `IEvent`.

interface

IEventTypeRegistry

Assembly: EricksonLopez.Events
public interface IEventTypeRegistry

Defines a registry for resolving event type metadata and descriptors.

Members (5)

  • methodGetAllDescriptors
    IReadOnlyCollection<EventTypeDescriptor> GetAllDescriptors()

    Retrieves all registered event type descriptors.

    Returns: A read-only collection containing all registered `EventTypeDescriptor` instances.

  • methodTryGetDescriptor
    bool TryGetDescriptor(EventType eventType, out EventTypeDescriptor? descriptor)

    Attempts to retrieve the descriptor associated with the specified semantic event type.

    eventType: EventType
    The semantic event type identifier.
    descriptor: out EventTypeDescriptor?
    When this method returns, contains the descriptor if found; otherwise, `null`.

    Returns: `true` if the descriptor was found; otherwise, `false`.

  • methodTryGetDescriptor
    bool TryGetDescriptor(EventType eventType, EventVersion version, out EventTypeDescriptor? descriptor)

    Attempts to retrieve the descriptor associated with the specified semantic event type and contract schema version.

    eventType: EventType
    The semantic event type identifier.
    version: EventVersion
    The schema contract version.
    descriptor: out EventTypeDescriptor?
    When this method returns, contains the descriptor if found; otherwise, `null`.

    Returns: `true` if the descriptor was found; otherwise, `false`.

  • methodTryGetDescriptor
    bool TryGetDescriptor(Type clrType, out EventTypeDescriptor? descriptor)

    Attempts to retrieve the descriptor associated with the specified CLR event type.

    clrType: Type
    The CLR `Type` of the event.
    descriptor: out EventTypeDescriptor?
    When this method returns, contains the descriptor if found; otherwise, `null`.

    Returns: `true` if the descriptor was found; otherwise, `false`.

    Exceptions: ArgumentNullException: `clrType` is `null`

  • methodTryGetDescriptor<TEvent>
    bool TryGetDescriptor<TEvent>(out EventTypeDescriptor? descriptor) where TEvent : IEvent

    Attempts to retrieve the descriptor associated with the generic event type.

    descriptor: out EventTypeDescriptor?
    When this method returns, contains the descriptor if found; otherwise, `null`.

    Returns: `true` if the descriptor was found; otherwise, `false`.

    Type parameters: TEvent: The type of the event.

class

StaticEventTypeRegistry

Assembly: EricksonLopez.Events
public static class StaticEventTypeRegistry

Provides statically cached access to event descriptors with zero runtime overhead.

Members (8)

  • methodFreeze
    public static void Freeze()

    Freezes the global registry, preventing any subsequent calls to `SetCurrent` or `Reset`.

  • methodGetDescriptor<TEvent>
    public static EventTypeDescriptor GetDescriptor<TEvent>() where TEvent : IEvent

    Retrieves the statically cached descriptor for the specified event type.

    Returns: The resolved `EventTypeDescriptor` for `TEvent`.

    Type parameters: TEvent: The type of the event.

  • methodGetEventType<TEvent>
    public static EventType GetEventType<TEvent>() where TEvent : IEvent

    Retrieves the semantic event type for the specified event type.

    Returns: The semantic `EventType` for `TEvent`.

    Type parameters: TEvent: The type of the event.

  • methodGetVersion<TEvent>
    public static EventVersion GetVersion<TEvent>() where TEvent : IEvent

    Retrieves the schema contract version for the specified event type.

    Returns: The schema `EventVersion` for `TEvent`.

    Type parameters: TEvent: The type of the event.

  • methodReset
    public static void Reset()

    Resets the global registry to its default empty state (intended strictly for unit testing isolation).

    Exceptions: InvalidOperationException: The registry is frozen and cannot be reset

  • methodSetCurrent
    public static void SetCurrent(IEventTypeRegistry registry, bool allowOverride = false)

    Sets the global active `IEventTypeRegistry`.

    registry: IEventTypeRegistry
    The registry to set.
    allowOverride: bool
    Whether to allow overriding an already initialized registry (intended for test suites).

    Exceptions: ArgumentNullException: `registry` is `null`; InvalidOperationException: The registry is already initialized and `allowOverride` is `false`, or the registry is frozen

  • propertyCurrent
    public static IEventTypeRegistry Current { get; set; }

    Gets or sets the global active `IEventTypeRegistry`.

    Setting this property initializes the global registry. Re-assigning it after initialization throws `InvalidOperationException` to prevent unauthorized in-process registry poisoning. In test scenarios, use `SetCurrent(IEventTypeRegistry, bool)` with allowOverride: true or `Reset`. Exceptions: InvalidOperationException: The registry was already initialized and cannot be overwritten directly

  • propertyIsFrozen
    public static bool IsFrozen { get; }

    Gets a value indicating whether the registry has been frozen against runtime modification.

EricksonLopez.Events.Serialization.SystemTextJson#

1
class

EventsJsonSerializerOptionsExtensions

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public static class EventsJsonSerializerOptionsExtensions

Provides extension methods for configuring `JsonSerializerOptions` with event serialization converters.

Members (2)

  • methodAddEventsConverters
    public static JsonSerializerOptions AddEventsConverters(this JsonSerializerOptions options)

    Adds Native AOT compatible event serialization converters to the options instance.

    options: this JsonSerializerOptions
    The `JsonSerializerOptions` instance to configure.

    Returns: The configured `JsonSerializerOptions` instance.

    Exceptions: ArgumentNullException: `options` is `null`

  • methodCreateDefaultOptions
    public static JsonSerializerOptions CreateDefaultOptions()

    Creates a new `JsonSerializerOptions` instance configured with default event serialization converters.

    Returns: A new `JsonSerializerOptions` instance configured for event serialization.

EricksonLopez.Events.Serialization.SystemTextJson.Converters#

9
class

CausationIdJsonConverter

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public sealed class CausationIdJsonConverter : JsonConverter<CausationId>
Inherits: JsonConverter<CausationId>

Provides Native AOT compatible JSON conversion for `CausationId`.

Members (2)

  • methodRead
    public override CausationId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    reader: ref Utf8JsonReader
    typeToConvert: Type
    options: JsonSerializerOptions
  • methodWrite
    public override void Write(Utf8JsonWriter writer, CausationId value, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    writer: Utf8JsonWriter
    value: CausationId
    options: JsonSerializerOptions
class

CorrelationIdJsonConverter

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public sealed class CorrelationIdJsonConverter : JsonConverter<CorrelationId>
Inherits: JsonConverter<CorrelationId>

Provides Native AOT compatible JSON conversion for `CorrelationId`.

Members (2)

  • methodRead
    public override CorrelationId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    reader: ref Utf8JsonReader
    typeToConvert: Type
    options: JsonSerializerOptions
  • methodWrite
    public override void Write(Utf8JsonWriter writer, CorrelationId value, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    writer: Utf8JsonWriter
    value: CorrelationId
    options: JsonSerializerOptions
class

EventEnvelopeJsonConverterFactory

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public sealed class EventEnvelopeJsonConverterFactory : JsonConverterFactory
Inherits: JsonConverterFactory

Provides a `JsonConverterFactory` for constructing `EventEnvelopeJsonConverter<TEvent>` instances for generic `EventEnvelope<TEvent>` types.

Members (2)

  • methodCanConvert
    public override bool CanConvert(Type typeToConvert)

    Inherits documentation from base type or interface.

    typeToConvert: Type
  • methodCreateConverter
    public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    typeToConvert: Type
    options: JsonSerializerOptions
class

EventEnvelopeJsonConverter<TEvent>

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public sealed class EventEnvelopeJsonConverter<TEvent> : JsonConverter<EventEnvelope<TEvent>> where TEvent : IEvent
Inherits: JsonConverter<EventEnvelope<TEvent>>

Provides Native AOT compatible JSON conversion for `EventEnvelope<TEvent>`.

Remarks:

Type parameters: TEvent: The type of the event payload.

Members (2)

  • methodRead
    public override EventEnvelope<TEvent> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    reader: ref Utf8JsonReader
    typeToConvert: Type
    options: JsonSerializerOptions
  • methodWrite
    public override void Write(Utf8JsonWriter writer, EventEnvelope<TEvent> value, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    writer: Utf8JsonWriter
    value: EventEnvelope<TEvent>
    options: JsonSerializerOptions
class

EventIdJsonConverter

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public sealed class EventIdJsonConverter : JsonConverter<EventId>
Inherits: JsonConverter<EventId>

Provides Native AOT compatible JSON conversion for `EventId`.

Members (2)

  • methodRead
    public override EventId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    reader: ref Utf8JsonReader
    typeToConvert: Type
    options: JsonSerializerOptions
  • methodWrite
    public override void Write(Utf8JsonWriter writer, EventId value, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    writer: Utf8JsonWriter
    value: EventId
    options: JsonSerializerOptions
class

EventMetadataJsonConverter

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public sealed class EventMetadataJsonConverter : JsonConverter<EventMetadata>
Inherits: JsonConverter<EventMetadata>

Provides Native AOT compatible JSON conversion for `EventMetadata`.

Members (2)

  • methodRead
    public override EventMetadata Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    reader: ref Utf8JsonReader
    typeToConvert: Type
    options: JsonSerializerOptions
  • methodWrite
    public override void Write(Utf8JsonWriter writer, EventMetadata value, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    writer: Utf8JsonWriter
    value: EventMetadata
    options: JsonSerializerOptions
class

EventTypeJsonConverter

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public sealed class EventTypeJsonConverter : JsonConverter<EventType>
Inherits: JsonConverter<EventType>

Provides Native AOT compatible JSON conversion for `EventType`.

Members (2)

  • methodRead
    public override EventType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    reader: ref Utf8JsonReader
    typeToConvert: Type
    options: JsonSerializerOptions
  • methodWrite
    public override void Write(Utf8JsonWriter writer, EventType value, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    writer: Utf8JsonWriter
    value: EventType
    options: JsonSerializerOptions
class

EventVersionJsonConverter

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public sealed class EventVersionJsonConverter : JsonConverter<EventVersion>
Inherits: JsonConverter<EventVersion>

Provides Native AOT compatible JSON conversion for `EventVersion`.

Members (2)

  • methodRead
    public override EventVersion Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    reader: ref Utf8JsonReader
    typeToConvert: Type
    options: JsonSerializerOptions
  • methodWrite
    public override void Write(Utf8JsonWriter writer, EventVersion value, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    writer: Utf8JsonWriter
    value: EventVersion
    options: JsonSerializerOptions
class

TenantIdJsonConverter

Assembly: EricksonLopez.Events.Serialization.SystemTextJson
public sealed class TenantIdJsonConverter : JsonConverter<TenantId>
Inherits: JsonConverter<TenantId>

Provides Native AOT compatible JSON conversion for `TenantId`.

Members (2)

  • methodRead
    public override TenantId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    reader: ref Utf8JsonReader
    typeToConvert: Type
    options: JsonSerializerOptions
  • methodWrite
    public override void Write(Utf8JsonWriter writer, TenantId value, JsonSerializerOptions options)

    Inherits documentation from base type or interface.

    writer: Utf8JsonWriter
    value: TenantId
    options: JsonSerializerOptions

EricksonLopez.Events.Testing#

4
class

EventEnvelopeTestBuilder<TEvent>

Assembly: EricksonLopez.Events.Testing
public sealed class EventEnvelopeTestBuilder<TEvent> where TEvent : IEvent

Provides a fluent test builder for constructing synthetic `EventEnvelope<TEvent>` and `EventMetadata` instances in unit tests.

Remarks:

Type parameters: TEvent: The type of the event payload.

Members (12)

  • constructorEventEnvelopeTestBuilder
    public EventEnvelopeTestBuilder(TEvent payload)

    Initializes a new instance of the `EventEnvelopeTestBuilder<TEvent>` class wrapping the specified payload.

    payload: TEvent
    The event payload.

    Exceptions: ArgumentNullException: `payload` is `null`

  • methodBuild
    public EventEnvelope<TEvent> Build()

    Builds the configured `EventEnvelope<TEvent>` instance.

    Returns: A new `EventEnvelope<TEvent>` instance.

  • methodWithCausationId
    public EventEnvelopeTestBuilder<TEvent> WithCausationId(string causationId)

    Sets the causation identifier in the metadata.

    causationId: string
    The causation identifier string.

    Returns: The current builder instance.

  • methodWithContentType
    public EventEnvelopeTestBuilder<TEvent> WithContentType(string contentType)

    Sets the payload MIME content type in the metadata.

    contentType: string
    The MIME content type string.

    Returns: The current builder instance.

  • methodWithCorrelationId
    public EventEnvelopeTestBuilder<TEvent> WithCorrelationId(string correlationId)

    Sets the correlation identifier in the metadata.

    correlationId: string
    The correlation identifier string.

    Returns: The current builder instance.

  • methodWithHeader
    public EventEnvelopeTestBuilder<TEvent> WithHeader(string key, string value)

    Adds a custom header to the event metadata.

    key: string
    The header key.
    value: string
    The header value.

    Returns: The current builder instance.

    Exceptions: ArgumentException: `key` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `value` is `null`

  • methodWithId
    public EventEnvelopeTestBuilder<TEvent> WithId(EventId id)

    Sets the event identifier.

    id: EventId
    The event identifier.

    Returns: The current builder instance.

  • methodWithOccurredAt
    public EventEnvelopeTestBuilder<TEvent> WithOccurredAt(DateTimeOffset occurredAt)

    Sets the timestamp when the event occurred.

    occurredAt: DateTimeOffset
    The occurrence timestamp.

    Returns: The current builder instance.

  • methodWithSource
    public EventEnvelopeTestBuilder<TEvent> WithSource(string source)

    Sets the originating source identifier or URI in the metadata.

    source: string
    The source identifier string.

    Returns: The current builder instance.

  • methodWithTenantId
    public EventEnvelopeTestBuilder<TEvent> WithTenantId(string tenantId)

    Sets the tenant identifier in the metadata.

    tenantId: string
    The tenant identifier string.

    Returns: The current builder instance.

  • methodWithType
    public EventEnvelopeTestBuilder<TEvent> WithType(string eventType)

    Sets the semantic event type name.

    eventType: string
    The semantic event type name.

    Returns: The current builder instance.

  • methodWithVersion
    public EventEnvelopeTestBuilder<TEvent> WithVersion(uint version)

    Sets the schema contract version.

    version: uint
    The contract version.

    Returns: The current builder instance.

class

EventTestBuilder

Assembly: EricksonLopez.Events.Testing
public static class EventTestBuilder

Provides factory methods for building synthetic test events and envelopes.

Members (1)

  • methodFor<TEvent>
    public static EventEnvelopeTestBuilder<TEvent> For<TEvent>(TEvent payload) where TEvent : IEvent

    Creates a fluent test builder for an `EventEnvelope<TEvent>`.

    payload: TEvent
    The event payload.

    Returns: A new `EventEnvelopeTestBuilder<TEvent>` instance.

    Type parameters: TEvent: The type of the event payload. Exceptions: ArgumentNullException: `payload` is `null`

class

FakeEventPublisher

Assembly: EricksonLopez.Events.Testing
public sealed class FakeEventPublisher : IEventPublisher
Implements: IEventPublisher

Provides an in-memory fake event publisher for testing event emission, verifying assertions, and inspecting published events.

Members (15)

  • methodGetEvents<TEvent>
    public IReadOnlyList<TEvent> GetEvents<TEvent>() where TEvent : IEvent

    Retrieves all published events of the specified type.

    Returns: A read-only list of matching events.

    Type parameters: TEvent: The type of the event to filter by.

  • methodGetEvents<TEvent>
    public IReadOnlyList<TEvent> GetEvents<TEvent>(Func<TEvent, bool> predicate) where TEvent : IEvent

    Retrieves all published events of the specified type that match the predicate.

    predicate: Func<TEvent, bool>
    The filter predicate to apply to published events.

    Returns: A read-only list of matching events.

    Type parameters: TEvent: The type of the event to filter by. Exceptions: ArgumentNullException: `predicate` is `null`

  • methodGetSingleEvent<TEvent>
    public TEvent GetSingleEvent<TEvent>() where TEvent : IEvent

    Retrieves the single published event of the specified type.

    Returns: The single published event instance.

    Type parameters: TEvent: The type of the event to retrieve. Exceptions: InvalidOperationException: No event or more than one event of the specified type was published

  • methodPublishAsync<TEvent>
    public ValueTask PublishAsync<TEvent>(TEvent eventInstance, CancellationToken cancellationToken = default) where TEvent : IEvent

    Publishes an event to all registered subscribers asynchronously.

    eventInstance: TEvent
    The event instance to publish. Must not be `null`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous publish operation.

    Type parameters: TEvent: The concrete event type to publish. Must implement `IEvent`. Exceptions: ArgumentNullException: `eventInstance` is `null`

  • methodPublishEnvelopeAsync<TEvent>
    public ValueTask PublishEnvelopeAsync<TEvent>(EricksonLopez.Events.Envelopes.IEventEnvelope<TEvent> envelope, CancellationToken cancellationToken = default) where TEvent : IEvent

    Publishes an event wrapped in an envelope carrying ambient metadata to all registered subscribers asynchronously.

    envelope: EricksonLopez.Events.Envelopes.IEventEnvelope<TEvent>
    The event envelope carrying payload and ambient metadata. Must not be `null`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous publish operation.

    Type parameters: TEvent: The concrete event type to publish. Must implement `IEvent`.

  • methodReset
    public void Reset()

    Clears all recorded published events and resets simulated failure states.

  • methodShouldHavePublished<TEvent>
    public FakeEventPublisher ShouldHavePublished<TEvent>() where TEvent : IEvent

    Asserts that at least one event of the specified type was published.

    Returns: The current fake publisher instance for chaining.

    Type parameters: TEvent: The expected event type. Exceptions: InvalidOperationException: No event of the specified type was published

  • methodShouldHavePublished<TEvent>
    public FakeEventPublisher ShouldHavePublished<TEvent>(Func<TEvent, bool> predicate) where TEvent : IEvent

    Asserts that at least one event of the specified type matching the predicate was published.

    predicate: Func<TEvent, bool>
    The predicate to match against.

    Returns: The current fake publisher instance for chaining.

    Type parameters: TEvent: The expected event type. Exceptions: ArgumentNullException: `predicate` is `null`; InvalidOperationException: No event of the specified type matching the predicate was published

  • methodShouldHavePublishedCount<TEvent>
    public FakeEventPublisher ShouldHavePublishedCount<TEvent>(int expectedCount) where TEvent : IEvent

    Asserts that exactly the specified number of events of the specified type were published.

    expectedCount: int
    The expected number of published events.

    Returns: The current fake publisher instance for chaining.

    Type parameters: TEvent: The event type. Exceptions: ArgumentOutOfRangeException: `expectedCount` is negative; InvalidOperationException: The actual count of published events does not match `expectedCount`

  • methodShouldNotHavePublished<TEvent>
    public FakeEventPublisher ShouldNotHavePublished<TEvent>() where TEvent : IEvent

    Asserts that no events of the specified type were published.

    Returns: The current fake publisher instance for chaining.

    Type parameters: TEvent: The event type. Exceptions: InvalidOperationException: One or more events of the specified type were published

  • methodShouldNotHavePublished<TEvent>
    public FakeEventPublisher ShouldNotHavePublished<TEvent>(Func<TEvent, bool> predicate) where TEvent : IEvent

    Asserts that no events of the specified type matching the predicate were published.

    predicate: Func<TEvent, bool>
    The predicate to check.

    Returns: The current fake publisher instance for chaining.

    Type parameters: TEvent: The event type. Exceptions: ArgumentNullException: `predicate` is `null`; InvalidOperationException: One or more events of the specified type matching the predicate were published

  • methodSimulateFailure
    public void SimulateFailure(Exception exception, int failureCount = 1)

    Simulates a failure on subsequent publish attempts by throwing the specified exception.

    exception: Exception
    The exception to throw.
    failureCount: int
    The number of subsequent publishes that should fail. The default is 1.

    Exceptions: ArgumentNullException: `exception` is `null`; ArgumentOutOfRangeException: `failureCount` is less than or equal to zero

  • propertyCount
    public int Count { get; }

    Gets the total number of events published.

  • propertyPublishedEnvelopes
    public IReadOnlyList<EricksonLopez.Events.Envelopes.IEventEnvelope> PublishedEnvelopes { get; }

    Gets a read-only list of all published event envelopes in chronological order.

  • propertyPublishedEvents
    public IReadOnlyList<IEvent> PublishedEvents { get; }

    Gets a read-only list of all published events in chronological order.

class

TestEventHandler<TEvent>

Assembly: EricksonLopez.Events.Testing
public sealed class TestEventHandler<TEvent> : IEventHandler<TEvent> where TEvent : IEvent
Implements: IEventHandler<TEvent>

Provides a test spy and stub implementation of `IEventHandler<TEvent>` for verifying handler executions and simulating delays or failures.

Remarks:

Type parameters: TEvent: The event type to handle.

Members (11)

  • methodHandleAsync
    public async ValueTask HandleAsync(TEvent eventInstance, CancellationToken cancellationToken = default)

    Handles the specified event asynchronously.

    eventInstance: TEvent
    The event instance to process. Must not be `null`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous handling operation.

    Exceptions: ArgumentNullException: `eventInstance` is `null`

  • methodReset
    public void Reset()

    Clears all recorded handled events, timestamps, and resets configurations.

  • methodWithCallback
    public TestEventHandler<TEvent> WithCallback(Action<TEvent> callback)

    Configures a synchronous callback delegate to execute on handle.

    callback: Action<TEvent>
    The callback delegate.

    Returns: The current instance for chaining.

    Exceptions: ArgumentNullException: `callback` is `null`

  • methodWithCallback
    public TestEventHandler<TEvent> WithCallback(Func<TEvent, CancellationToken, ValueTask> asyncCallback)

    Configures an asynchronous callback delegate to execute on handle.

    asyncCallback: Func<TEvent, CancellationToken, ValueTask>
    The async callback delegate.

    Returns: The current instance for chaining.

    Exceptions: ArgumentNullException: `asyncCallback` is `null`

  • methodWithDelay
    public TestEventHandler<TEvent> WithDelay(TimeSpan delay)

    Configures the handler to simulate an execution delay.

    delay: TimeSpan
    The delay duration.

    Returns: The current instance for chaining.

    Exceptions: ArgumentOutOfRangeException: `delay` is less than or equal to `TimeSpan.Zero`

  • methodWithException
    public TestEventHandler<TEvent> WithException(Exception exception)

    Configures the handler to throw the specified exception whenever invoked.

    exception: Exception
    The exception to throw.

    Returns: The current instance for chaining.

    Exceptions: ArgumentNullException: `exception` is `null`

  • propertyExecutionTimestamps
    public IReadOnlyList<DateTimeOffset> ExecutionTimestamps { get; }

    Gets the timestamps when each event was handled.

  • propertyHandledEvents
    public IReadOnlyList<TEvent> HandledEvents { get; }

    Gets a read-only list of all events handled by this test handler in chronological order.

  • propertyInvocationCount
    public int InvocationCount { get; }

    Gets the number of times this handler has been invoked.

  • propertyLastEvent
    public TEvent? LastEvent { get; }

    Gets the last event handled, or `null` if none handled.

  • propertyWasInvoked
    public bool WasInvoked { get; }

    Gets a value indicating whether this handler was invoked at least once.

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.