Table of Contents

Class EventContext

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

Represents the context in which an event exists in - typically what it was appended with.

public record EventContext : IEquatable<EventContext>
Inheritance
EventContext
Implements
Inherited Members

Constructors

EventContext(EventSourceType, EventSourceId, EventStreamType, EventStreamId, EventSequenceNumber, DateTimeOffset, EventStoreName, EventStoreNamespaceName, CorrelationId, IEnumerable<Causation>, Identity, EventObservationState)

Represents the context in which an event exists in - typically what it was appended with.

public EventContext(EventSourceType EventSourceType, EventSourceId EventSourceId, EventStreamType EventStreamType, EventStreamId EventStreamId, EventSequenceNumber SequenceNumber, DateTimeOffset Occurred, EventStoreName EventStore, EventStoreNamespaceName Namespace, CorrelationId CorrelationId, IEnumerable<Causation> Causation, Identity CausedBy, EventObservationState ObservationState = EventObservationState.Initial)

Parameters

EventSourceType EventSourceType

The EventSourceType.

EventSourceId EventSourceId

The EventSourceId.

EventStreamType EventStreamType

The EventStreamType.

EventStreamId EventStreamId

The EventStreamId.

SequenceNumber EventSequenceNumber

The EventSequenceNumber of the event as persisted in the event sequence.

Occurred DateTimeOffset

When it occurred.

EventStore EventStoreName

The EventStoreName the event belongs to.

Namespace EventStoreNamespaceName

The EventStoreNamespaceName the event belongs to.

CorrelationId CorrelationId

The CorrelationId for the event.

Causation IEnumerable<Causation>

A collection of Causation for what caused the event.

CausedBy Identity

A collection of Identities that caused the event.

ObservationState EventObservationState

Holds the state relevant for the observer observing.

Fields

Empty

Creates an 'empty' EventContext with the event source id set to empty and all properties default.

public static readonly EventContext Empty

Field Value

EventContext

A new EventContext.

Properties

Causation

A collection of Causation for what caused the event.

public IEnumerable<Causation> Causation { get; init; }

Property Value

IEnumerable<Causation>

CausedBy

A collection of Identities that caused the event.

public Identity CausedBy { get; init; }

Property Value

Identity

CorrelationId

The CorrelationId for the event.

public CorrelationId CorrelationId { get; init; }

Property Value

CorrelationId

EventSourceId

public EventSourceId EventSourceId { get; init; }

Property Value

EventSourceId

EventSourceType

public EventSourceType EventSourceType { get; init; }

Property Value

EventSourceType

EventStore

The EventStoreName the event belongs to.

public EventStoreName EventStore { get; init; }

Property Value

EventStoreName

EventStreamId

public EventStreamId EventStreamId { get; init; }

Property Value

EventStreamId

EventStreamType

public EventStreamType EventStreamType { get; init; }

Property Value

EventStreamType

Namespace

The EventStoreNamespaceName the event belongs to.

public EventStoreNamespaceName Namespace { get; init; }

Property Value

EventStoreNamespaceName

ObservationState

Holds the state relevant for the observer observing.

public EventObservationState ObservationState { get; init; }

Property Value

EventObservationState

Occurred

When it occurred.

public DateTimeOffset Occurred { get; init; }

Property Value

DateTimeOffset

SequenceNumber

The EventSequenceNumber of the event as persisted in the event sequence.

public EventSequenceNumber SequenceNumber { get; init; }

Property Value

EventSequenceNumber

Methods

EmptyWithEventSourceId(EventSourceId)

Creates an empty EventContext for a specific EventSourceId.

public static EventContext EmptyWithEventSourceId(EventSourceId eventSourceId)

Parameters

eventSourceId EventSourceId

EventSourceId to create for.

Returns

EventContext

A new EventContext.

From(EventStoreName, EventStoreNamespaceName, EventSourceType, EventSourceId, EventStreamType, EventStreamId, EventSequenceNumber, CorrelationId, DateTimeOffset?)

Creates a new EventContext from EventSourceId and other optional parameters.

public static EventContext From(EventStoreName eventStore, EventStoreNamespaceName @namespace, EventSourceType eventSourceType, EventSourceId eventSourceId, EventStreamType eventStreamType, EventStreamId eventStreamId, EventSequenceNumber sequenceNumber, CorrelationId correlationId, DateTimeOffset? occurred = null)

Parameters

eventStore EventStoreName

EventStoreName the context is for.

namespace EventStoreNamespaceName

EventStoreNamespaceName the context is for.

eventSourceType EventSourceType

EventSourceType to create from.

eventSourceId EventSourceId

EventSourceId to create from.

eventStreamType EventStreamType

EventStreamType to create from.

eventStreamId EventStreamId

EventStreamId to create from.

sequenceNumber EventSequenceNumber

The EventSequenceNumber of the event as persisted in the event sequence.

correlationId CorrelationId

The CorrelationId for the event.

occurred DateTimeOffset?

Optional occurred.

Returns

EventContext

A new EventContext.

WithState(EventObservationState)

Creates a copy of the context object with the new desired state.

public EventContext WithState(EventObservationState desiredState)

Parameters

desiredState EventObservationState

The desired state.

Returns

EventContext

A new copy with the desired state set.