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
serializerISecureJsonSerializertypeResolverITrustedTypeResolverupcasterPipelineIEventUpcasterPipeline
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
entriesIEnumerable<EventStreamEntry>The persisted stream entries to map.
cancellationTokenCancellationTokenToken observed during async secure deserialization.
Returns
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
messagesIEnumerable<EventMessage>The event messages to map.
cancellationTokenCancellationTokenToken observed during async secure deserialization.