Class EventTypes

Namespace
Cratis.Chronicle.Events
Assembly
Cratis.Chronicle.dll

Represents an implementation of IEventTypes.

public class EventTypes : IEventTypes
Inheritance
EventTypes
Implements
Inherited Members
Extension Methods

Constructors

EventTypes(IEventStore, IJsonSchemaGenerator, IClientArtifactsProvider, IEventTypeMigrators, bool)

Initializes a new instance of EventTypes.

public EventTypes(IEventStore eventStore, IJsonSchemaGenerator jsonSchemaGenerator, IClientArtifactsProvider clientArtifacts, IEventTypeMigrators eventTypeMigrators, bool enableEventTypeGenerationValidation = false)

Parameters

eventStore IEventStore

The IEventStore the event types belong to.

jsonSchemaGenerator IJsonSchemaGenerator

IJsonSchemaGenerator for generating JSON schemas from types.

clientArtifacts IClientArtifactsProvider

Optional IClientArtifactsProvider for the client artifacts.

eventTypeMigrators IEventTypeMigrators

IEventTypeMigrators for discovering event type migrators.

enableEventTypeGenerationValidation bool

Whether to enable event type generation chain validation on the server. Defaults to false.

EventTypes(IEventStore, IJsonSchemaGenerator, IClientArtifactsProvider, IEventTypeMigrators, bool, INamingPolicy?)

Initializes a new instance of EventTypes with the naming policy used for event payloads.

public EventTypes(IEventStore eventStore, IJsonSchemaGenerator jsonSchemaGenerator, IClientArtifactsProvider clientArtifacts, IEventTypeMigrators eventTypeMigrators, bool enableEventTypeGenerationValidation, INamingPolicy? namingPolicy)

Parameters

eventStore IEventStore

The event store the event types belong to.

jsonSchemaGenerator IJsonSchemaGenerator

The generator for event schemas.

clientArtifacts IClientArtifactsProvider

The provider of client artifacts.

eventTypeMigrators IEventTypeMigrators

The migrator discovery service.

enableEventTypeGenerationValidation bool

Whether to validate the generation chain on the server.

namingPolicy INamingPolicy

The naming policy, or null to preserve declared property names.

Properties

All

Get all EventType discovered event types.

public IImmutableList<EventType> All { get; }

Property Value

IImmutableList<EventType>

AllClrTypes

Get all event types as EventTypeRegistration.

public IImmutableList<Type> AllClrTypes { get; }

Property Value

IImmutableList<Type>

Methods

Discover()

Discover all event types from the entry assembly and dependencies.

public Task Discover()

Returns

Task

Awaitable task.

Exceptions

MultipleEventTypesWithSameIdFound

Thrown when more than one CLR type resolves to the same event type id and generation.

ArtifactPreparationReentered

Discovery reenters its own unfinished schema generation.

GetClrTypeFor(EventTypeId)

Get a Clr Type for a specific EventTypeId.

public Type GetClrTypeFor(EventTypeId eventTypeId)

Parameters

eventTypeId EventTypeId

EventTypeId to get for.

Returns

Type

The Clr Type.

GetClrTypeFor(EventTypeId, EventTypeGeneration)

Get a Clr Type for a specific EventTypeId and EventTypeGeneration.

public Type GetClrTypeFor(EventTypeId eventTypeId, EventTypeGeneration generation)

Parameters

eventTypeId EventTypeId

EventTypeId to get for.

generation EventTypeGeneration

EventTypeGeneration to get for.

Returns

Type

The Clr Type.

GetEventTypeFor(Type)

Get a EventType for a specific Clr Type.

public EventType GetEventTypeFor(Type clrType)

Parameters

clrType Type

Clr Type to get for.

Returns

EventType

The EventType.

Remarks

Reporting the miss as TypeIsNotAnEventType rather than letting the lookup fall out as a LINQ exception matters most to the model-bound projection attributes: their generic type argument is unconstrained, so nothing at compile time relates it to an event type and this is the first place the mistake can be named. The fluent projection builder already answers the same condition the same way.

Exceptions

TypeIsNotAnEventType

Thrown when the type is not a registered event type.

GetSchemaFor(EventTypeId)

Get the JsonSchema for an EventTypeId.

public JsonSchema GetSchemaFor(EventTypeId eventTypeId)

Parameters

eventTypeId EventTypeId

EventTypeId to get for.

Returns

JsonSchema

JsonSchema for the event type.

HasFor(EventTypeId)

Check if there is a registered Clr Type for a specific EventTypeId.

public bool HasFor(EventTypeId eventTypeId)

Parameters

eventTypeId EventTypeId

EventTypeId to check for.

Returns

bool

True if there is, false if not.

HasFor(Type)

Check if there is a registered EventTypeId for a specific Clr Type.

public bool HasFor(Type clrType)

Parameters

clrType Type

Clr Type to check for.

Returns

bool

True if there is, false if not.

Register()

Register all event types with the Chronicle.

public Task Register()

Returns

Task

Awaitable task.

Exceptions

ArtifactPreparationReentered

Registration reenters unfinished local preparation.