Class ResolvedEventPayload
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
Serializes an event payload through the type-info resolver a host configured, translating a missing declaration into EventTypeNotDeclaredException.
public static class ResolvedEventPayload
- Inheritance
-
ResolvedEventPayload
- Inherited Members
Remarks
Every store that honours a host-supplied resolver reaches the serializer the same way, and each one used to write that call out for itself. Identical code in ten places is where a contract diverges: the stores disagreed for a long time about whether an undeclared type ended the append with a thrown exception or a returned failure, and each provider's own test agreed with its own provider. Routing the call through one place makes the answer a property of this method rather than of whichever store the consumer happens to have chosen.
The bytes are unchanged. This performs the same resolver lookup and the same serializer call the stores performed inline, so an event whose type is declared serializes exactly as before — only the failure path is new.
Methods
Serialize(IDomainEvent, JsonSerializerOptions, string?, string?)
Serializes an event using the resolver carried by the supplied options.
public static byte[] Serialize(IDomainEvent domainEvent, JsonSerializerOptions jsonOptions, string? aggregateId, string? aggregateType)
Parameters
domainEventIDomainEventThe event to serialize.
jsonOptionsJsonSerializerOptionsCanonical serializer options carrying the host's type-info resolver.
aggregateIdstringThe stream the append targets, reported on refusal.
aggregateTypestringThe aggregate type the append targets, reported on refusal.
Returns
- byte[]
The UTF-8 encoded event payload.
Exceptions
- ArgumentNullException
domainEventorjsonOptionsis null.- EventTypeNotDeclaredException
The resolver does not declare
domainEvent's runtime type. Nothing is written.