Skip to main content
Table of Contents

Class EventMapperFactory

Namespace
Stratara.Shared.EventSourcing.Mapping
Assembly
Stratara.Shared.dll

Default IEventMapperFactory implementation. Materializes typed IEvent instances from persisted EventStreamEntry rows or wire-level EventMessage envelopes by resolving the runtime event type, decrypting / deserializing the JSON payload through ISecureJsonSerializer, and constructing Event<TEvent> via a per-type cached compiled lambda factory.

public sealed class EventMapperFactory : IEventMapperFactory
Inheritance
EventMapperFactory
Implements
Inherited Members
Extension Methods

Remarks

The factory cache is process-wide and unbounded; the framework assumes a finite set of event types per host. AAD on the encrypted payload uses the subject (data-owner) tenant id, which matches TenantId.

Constructors

EventMapperFactory(ISecureJsonSerializer, ITrustedTypeResolver, IEventUpcasterPipeline)

Default IEventMapperFactory implementation. Materializes typed IEvent instances from persisted EventStreamEntry rows or wire-level EventMessage envelopes by resolving the runtime event type, decrypting / deserializing the JSON payload through ISecureJsonSerializer, and constructing Event<TEvent> via a per-type cached compiled lambda factory.

public EventMapperFactory(ISecureJsonSerializer serializer, ITrustedTypeResolver typeResolver, IEventUpcasterPipeline upcasterPipeline)

Parameters

serializer ISecureJsonSerializer
typeResolver ITrustedTypeResolver
upcasterPipeline IEventUpcasterPipeline

Remarks

The factory cache is process-wide and unbounded; the framework assumes a finite set of event types per host. AAD on the encrypted payload uses the subject (data-owner) tenant id, which matches TenantId.

Methods

MapToEventsAsync(IEnumerable<EventStreamEntry>, CancellationToken)

Map persisted stream entries to materialised events.

public Task<IReadOnlyList<IEvent>> MapToEventsAsync(IEnumerable<EventStreamEntry> entries, CancellationToken cancellationToken = default)

Parameters

entries IEnumerable<EventStreamEntry>

The persisted stream entries to map.

cancellationToken CancellationToken

Token observed during async secure deserialization.

Returns

Task<IReadOnlyList<IEvent>>

MapToEventsAsync(IEnumerable<EventMessage>, CancellationToken)

Map wire-level event messages (e.g. from a bus) to materialised events.

public Task<IReadOnlyList<IEvent>> MapToEventsAsync(IEnumerable<EventMessage> messages, CancellationToken cancellationToken = default)

Parameters

messages IEnumerable<EventMessage>

The event messages to map.

cancellationToken CancellationToken

Token observed during async secure deserialization.

Returns

Task<IReadOnlyList<IEvent>>