Skip to content

EventTypeRegistry Class

Maps event identifier URIs to the payload types that model them, and deserializes payloads through that map.

C#
public sealed class EventTypeRegistry

Inheritance System.Object → EventTypeRegistry

Remarks

The registry is filled during configuration and read at validation time; registration is not synchronized, so it belongs at startup, which is where the DI extension calls it. An event dictionary package - the CAEP one, for instance - is nothing but a set of registrations over this mechanism.

Constructors

EventTypeRegistry(JsonSerializerOptions) Constructor

Maps event identifier URIs to the payload types that model them, and deserializes payloads through that map.

C#
public EventTypeRegistry(System.Text.Json.JsonSerializerOptions? serializerOptions=null);

Parameters

serializerOptions System.Text.Json.JsonSerializerOptions

Options for payload deserialization; null takes the serializer's defaults. Property-name matching stays exact either way - wire names on payload types belong in JsonPropertyName attributes, where the profiling specification's spelling is visible next to the member it names.

Remarks

The registry is filled during configuration and read at validation time; registration is not synchronized, so it belongs at startup, which is where the DI extension calls it. An event dictionary package - the CAEP one, for instance - is nothing but a set of registrations over this mechanism.

Methods

EventTypeRegistry.Deserialize(string, JsonObject) Method

Deserializes an event's payload: into its registered type when the event identifier is known, into UnknownEventPayload when it is not.

C#
public Abblix.SecurityEvents.Events.IEventPayload Deserialize(string eventType, System.Text.Json.Nodes.JsonObject payload);

Parameters

eventType System.String

The event identifier URI.

payload System.Text.Json.Nodes.JsonObject

The payload object from the "events" claim.

Returns

IEventPayload
The typed payload, never null.

Exceptions

System.Text.Json.JsonException
The payload does not deserialize into the registered type. A malformed payload of a KNOWN type is a real error - the transmitter and receiver disagree about a shape both claim to know - unlike an unknown type, which is the forward-compatibility case the passthrough exists for.

EventTypeRegistry.Register<TPayload>(string) Method

Registers a payload type for an event identifier.

C#
public void Register<TPayload>(string eventType)
    where TPayload : Abblix.SecurityEvents.Events.IEventPayload;

Type parameters

TPayload

The type modelling the event's payload.

Parameters

eventType System.String

The event identifier URI, exactly as transmitters spell it - RFC 8417 Section 2.2 asks for stable values, and the comparison here is an exact string match.

Exceptions

System.ArgumentException
The event identifier is already registered. Two types for one URI would make the answer to "what does this event deserialize into" depend on registration order, which is the kind of fact nobody can read off the code.

EventTypeRegistry.TryGetPayloadType(string, Type) Method

Retrieves the payload type registered for an event identifier.

C#
public bool TryGetPayloadType(string eventType, out System.Type payloadType);

Parameters

eventType System.String

The event identifier URI.

payloadType System.Type

The registered type, when there is one.

Returns

System.Boolean