Class EventContext
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
EventSourceTypeThe EventSourceType.
EventSourceId
EventSourceIdThe EventSourceId.
EventStreamType
EventStreamTypeThe EventStreamType.
EventStreamId
EventStreamIdThe EventStreamId.
SequenceNumber
EventSequenceNumberThe EventSequenceNumber of the event as persisted in the event sequence.
Occurred
DateTimeOffsetWhen it occurred.
EventStore
EventStoreNameThe EventStoreName the event belongs to.
Namespace
EventStoreNamespaceNameThe EventStoreNamespaceName the event belongs to.
CorrelationId
CorrelationIdThe CorrelationId for the event.
Causation
IEnumerable<Causation>A collection of Causation for what caused the event.
CausedBy
IdentityA collection of Identities that caused the event.
ObservationState
EventObservationStateHolds 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
CausedBy
A collection of Identities that caused the event.
public Identity CausedBy { get; init; }
Property Value
CorrelationId
The CorrelationId for the event.
public CorrelationId CorrelationId { get; init; }
Property Value
EventSourceId
The EventSourceId.
public EventSourceId EventSourceId { get; init; }
Property Value
EventSourceType
The EventSourceType.
public EventSourceType EventSourceType { get; init; }
Property Value
EventStore
The EventStoreName the event belongs to.
public EventStoreName EventStore { get; init; }
Property Value
EventStreamId
The EventStreamId.
public EventStreamId EventStreamId { get; init; }
Property Value
EventStreamType
The EventStreamType.
public EventStreamType EventStreamType { get; init; }
Property Value
Namespace
The EventStoreNamespaceName the event belongs to.
public EventStoreNamespaceName Namespace { get; init; }
Property Value
ObservationState
Holds the state relevant for the observer observing.
public EventObservationState ObservationState { get; init; }
Property Value
Occurred
When it occurred.
public DateTimeOffset Occurred { get; init; }
Property Value
SequenceNumber
The EventSequenceNumber of the event as persisted in the event sequence.
public EventSequenceNumber SequenceNumber { get; init; }
Property Value
Methods
EmptyWithEventSourceId(EventSourceId)
Creates an empty EventContext for a specific EventSourceId.
public static EventContext EmptyWithEventSourceId(EventSourceId eventSourceId)
Parameters
eventSourceId
EventSourceIdEventSourceId 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
EventStoreNameEventStoreName the context is for.
namespace
EventStoreNamespaceNameEventStoreNamespaceName the context is for.
eventSourceType
EventSourceTypeEventSourceType to create from.
eventSourceId
EventSourceIdEventSourceId to create from.
eventStreamType
EventStreamTypeEventStreamType to create from.
eventStreamId
EventStreamIdEventStreamId to create from.
sequenceNumber
EventSequenceNumberThe EventSequenceNumber of the event as persisted in the event sequence.
correlationId
CorrelationIdThe 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
EventObservationStateThe desired state.
Returns
- EventContext
A new copy with the desired state set.