Class InMemoryEventStoreOptions
- Namespace
- Excalibur.EventSourcing.InMemory
- Assembly
- Excalibur.EventSourcing.InMemory.dll
Configuration options for the in-memory event store.
public sealed class InMemoryEventStoreOptions
- Inheritance
-
InMemoryEventStoreOptions
- Inherited Members
Properties
EventTypeInfoResolver
Gets or sets a source-generated JSON type-info resolver covering the application's domain event types and the runtime types of the values it places in Metadata, enabling a reflection-free serialization path under trimming and native AOT.
public IJsonTypeInfoResolver? EventTypeInfoResolver { get; set; }
Property Value
- IJsonTypeInfoResolver
The consumer's event type-info resolver, or null to serialize through reflection.
Examples
[JsonSourceGenerationOptions(
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
UseStringEnumConverter = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
[JsonSerializable(typeof(OrderPlaced))]
[JsonSerializable(typeof(string))]
internal sealed partial class AppEventContext : JsonSerializerContext;
services.AddInMemoryEventStore();
services.Configure<InMemoryEventStoreOptions>(
options => options.EventTypeInfoResolver = AppEventContext.Default);
Remarks
Domain events are consumer types the framework cannot source-generate, so with no resolver the store serializes them through the reflection-based JsonSerializer. That works under the JIT, but a native-AOT application published with reflection-based serialization disabled has no reflection path to fall back on and the first append fails. Set this to a JsonSerializerContext (or any IJsonTypeInfoResolver) covering those types to remove that dependency.
The stored wire format does not vary with this setting. The resolver supplies type metadata only; the property naming policy, string-enum representation and null handling are the store's own and are applied to whichever resolver is in use, so events written with a resolver are byte-identical to events written without one and remain readable by a host configured either way.
Metadata values are typed object and are therefore written as their runtime type. Declare
each closed value type the application actually stores — string, int, bool and so
on. Do not declare Dictionary<string, object> as a shortcut: it compiles and then throws on
the values it was meant to cover.