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
- Extension Methods
Constructors
EventContext(EventContext)
protected EventContext(EventContext original)
Parameters
originalEventContext
EventContext(EventType, EventSourceType, EventSourceId, EventStreamType, EventStreamId, EventSequenceNumber, DateTimeOffset, EventStoreName, EventStoreNamespaceName, CorrelationId, IEnumerable<Causation>, Identity, IEnumerable<Tag>, EventHash, EventObservationState, Subject)
Represents the context in which an event exists in - typically what it was appended with.
public EventContext(EventType EventType, EventSourceType EventSourceType, EventSourceId EventSourceId, EventStreamType EventStreamType, EventStreamId EventStreamId, EventSequenceNumber SequenceNumber, DateTimeOffset Occurred, EventStoreName EventStore, EventStoreNamespaceName Namespace, CorrelationId CorrelationId, IEnumerable<Causation> Causation, Identity CausedBy, IEnumerable<Tag> Tags, EventHash Hash, EventObservationState ObservationState = EventObservationState.Initial, Subject Subject = null)
Parameters
EventTypeEventTypeThe EventType of the event.
EventSourceTypeEventSourceTypeThe EventSourceType.
EventSourceIdEventSourceIdThe EventSourceId.
EventStreamTypeEventStreamTypeThe EventStreamType.
EventStreamIdEventStreamIdThe EventStreamId.
SequenceNumberEventSequenceNumberThe EventSequenceNumber of the event as persisted in the event sequence.
OccurredDateTimeOffsetWhen it occurred.
EventStoreEventStoreNameThe EventStoreName the event belongs to.
NamespaceEventStoreNamespaceNameThe EventStoreNamespaceName the event belongs to.
CorrelationIdCorrelationIdThe CorrelationId for the event.
CausationIEnumerable<Causation>A collection of Causation for what caused the event.
CausedByIdentityA collection of Identities that caused the event.
TagsIEnumerable<Tag>The tags associated with the event.
HashEventHashThe EventHash of the event content.
ObservationStateEventObservationStateHolds the state relevant for the observer observing.
SubjectSubjectThe Subject identifying the compliance target for this event. Always set — defaults to the EventSourceId value when no explicit subject is provided.
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
AppendedGeneration
Gets the generation the event was appended in, or null when unknown.
public EventTypeGeneration? AppendedGeneration { get; init; }
Property Value
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
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
EventSource
Gets the name of the registered event source definition the event was appended through. NotSet when it was not appended through a definition, including events stored before event sources existed.
public EventSourceName EventSource { get; init; }
Property Value
Remarks
Declared outside the primary constructor so existing positional construction and deconstruction shapes remain compatible.
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
EventType
The EventType of the event.
public EventType EventType { get; init; }
Property Value
Hash
The EventHash of the event content.
public EventHash Hash { get; init; }
Property Value
NamedTags
Gets the structured named tags associated with the event.
public IEnumerable<NamedTag> NamedTags { get; init; }
Property Value
Exceptions
- InvalidNamedTag
The supplied collection contains a null named tag.
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
Subject
The Subject identifying the compliance target for this event. Always set — defaults to the EventSourceId value when no explicit subject is provided.
public Subject Subject { get; init; }
Property Value
SubjectIsEventSourceId
Gets a value indicating whether the subject is the event source id (no explicit Subject was set, or Subject equals EventSourceId).
public bool SubjectIsEventSourceId { get; }
Property Value
Tags
The tags associated with the event.
public IEnumerable<Tag> Tags { get; init; }
Property Value
Methods
Deconstruct(out EventType, out EventSourceType, out EventSourceId, out EventStreamType, out EventStreamId, out EventSequenceNumber, out DateTimeOffset, out EventStoreName, out EventStoreNamespaceName, out CorrelationId, out IEnumerable<Causation>, out Identity, out IEnumerable<Tag>, out EventHash, out EventObservationState, out Subject)
public void Deconstruct(out EventType EventType, out EventSourceType EventSourceType, out EventSourceId EventSourceId, out EventStreamType EventStreamType, out EventStreamId EventStreamId, out EventSequenceNumber SequenceNumber, out DateTimeOffset Occurred, out EventStoreName EventStore, out EventStoreNamespaceName Namespace, out CorrelationId CorrelationId, out IEnumerable<Causation> Causation, out Identity CausedBy, out IEnumerable<Tag> Tags, out EventHash Hash, out EventObservationState ObservationState, out Subject Subject)
Parameters
EventTypeEventTypeEventSourceTypeEventSourceTypeEventSourceIdEventSourceIdEventStreamTypeEventStreamTypeEventStreamIdEventStreamIdSequenceNumberEventSequenceNumberOccurredDateTimeOffsetEventStoreEventStoreNameNamespaceEventStoreNamespaceNameCorrelationIdCorrelationIdCausationIEnumerable<Causation>CausedByIdentityTagsIEnumerable<Tag>HashEventHashObservationStateEventObservationStateSubjectSubject
EmptyWithEventSourceId(EventSourceId)
Creates an empty EventContext for a specific EventSourceId.
public static EventContext EmptyWithEventSourceId(EventSourceId eventSourceId)
Parameters
eventSourceIdEventSourceIdEventSourceId to create for.
Returns
- EventContext
A new EventContext.
Equals(EventContext?)
public virtual bool Equals(EventContext? other)
Parameters
otherEventContext
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
From(EventStoreName, EventStoreNamespaceName, EventType, 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, EventType eventType, EventSourceType eventSourceType, EventSourceId eventSourceId, EventStreamType eventStreamType, EventStreamId eventStreamId, EventSequenceNumber sequenceNumber, CorrelationId correlationId, DateTimeOffset? occurred = null)
Parameters
eventStoreEventStoreNameEventStoreName the context is for.
namespaceEventStoreNamespaceNameEventStoreNamespaceName the context is for.
eventTypeEventTypeEventType to create from.
eventSourceTypeEventSourceTypeEventSourceType to create from.
eventSourceIdEventSourceIdEventSourceId to create from.
eventStreamTypeEventStreamTypeEventStreamType to create from.
eventStreamIdEventStreamIdEventStreamId to create from.
sequenceNumberEventSequenceNumberThe EventSequenceNumber of the event as persisted in the event sequence.
correlationIdCorrelationIdThe CorrelationId for the event.
occurredDateTimeOffset?Optional occurrence time. Defaults to UtcNow when omitted.
Returns
- EventContext
A new EventContext.
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
ToString()
public override string ToString()
Returns
WithState(EventObservationState)
Creates a copy of the context object with the new desired state.
public EventContext WithState(EventObservationState desiredState)
Parameters
desiredStateEventObservationStateThe desired state.
Returns
- EventContext
A new copy with the desired state set.
Operators
operator ==(EventContext?, EventContext?)
public static bool operator ==(EventContext? left, EventContext? right)
Parameters
leftEventContextrightEventContext
Returns
operator !=(EventContext?, EventContext?)
public static bool operator !=(EventContext? left, EventContext? right)
Parameters
leftEventContextrightEventContext