Class EventSourceId<T>
- Namespace
- Cratis.Chronicle.Events
- Assembly
- Cratis.Chronicle.dll
Represents a type-safe event source identifier wrapping a strongly-typed value.
The generic type parameter is passed directly to ConceptAs<T>, giving value-equality
semantics over T while also supporting implicit conversion to and from
the untyped EventSourceId for wire compatibility.
public record EventSourceId<T> : ConceptAs<T>, IComparable<ConceptAs<T>>, IComparable<T>, IComparable, IEquatable<ConceptAs<T>>, IEquatable<EventSourceId<T>> where T : IComparable
Type Parameters
TThe type of the underlying value. Supported types are string, Guid, ConceptAs<T> wrappers over supported primitives, and comparable formattable values. Formattable values use invariant culture, with round-trip formatting for dates and times. Other types must provide a stable ToString() representation.
- Inheritance
-
ConceptAs<T>EventSourceId<T>
- Implements
-
IComparable<ConceptAs<T>>IComparable<T>IEquatable<ConceptAs<T>>
- Inherited Members
- Extension Methods
Constructors
EventSourceId(EventSourceId<T>)
protected EventSourceId(EventSourceId<T> original)
Parameters
originalEventSourceId<T>
EventSourceId(T)
Represents a type-safe event source identifier wrapping a strongly-typed value.
The generic type parameter is passed directly to ConceptAs<T>, giving value-equality
semantics over T while also supporting implicit conversion to and from
the untyped EventSourceId for wire compatibility.
public EventSourceId(T TypedValue)
Parameters
TypedValueTThe typed value that this identifier wraps.
Properties
EqualityContract
protected override Type EqualityContract { get; }
Property Value
TypedValue
The typed value that this identifier wraps.
public T TypedValue { get; init; }
Property Value
- T
Methods
Deconstruct(out T)
public void Deconstruct(out T TypedValue)
Parameters
TypedValueT
Equals(EventSourceId<T>?)
public virtual bool Equals(EventSourceId<T>? other)
Parameters
otherEventSourceId<T>
Returns
Equals(ConceptAs<T>?)
public override sealed bool Equals(ConceptAs<T>? other)
Parameters
otherConceptAs<T>
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
From(EventSourceId)
Create an EventSourceId<T> from an EventSourceId,
parsing its string value back into T.
public static EventSourceId<T> From(EventSourceId id)
Parameters
idEventSourceIdEventSourceId to convert from.
Returns
- EventSourceId<T>
A converted EventSourceId<T>.
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected override bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
Operators
operator ==(EventSourceId<T>?, EventSourceId<T>?)
public static bool operator ==(EventSourceId<T>? left, EventSourceId<T>? right)
Parameters
leftEventSourceId<T>rightEventSourceId<T>
Returns
implicit operator EventSourceId<T>(EventSourceId)
Implicitly convert from an untyped EventSourceId to EventSourceId<T>
by parsing the string value into T.
public static implicit operator EventSourceId<T>(EventSourceId id)
Parameters
idEventSourceIdEventSourceId to convert from.
Returns
- EventSourceId<T>
A converted EventSourceId<T>.
implicit operator EventSourceId(EventSourceId<T>)
Implicitly convert from EventSourceId<T> to an untyped EventSourceId by serializing the typed value to its string representation.
public static implicit operator EventSourceId(EventSourceId<T> id)
Parameters
idEventSourceId<T>EventSourceId<T> to convert from.
Returns
- EventSourceId
An untyped EventSourceId carrying the string representation.
implicit operator T(EventSourceId<T>)
Implicitly convert from EventSourceId<T> to T.
public static implicit operator T(EventSourceId<T> id)
Parameters
idEventSourceId<T>EventSourceId<T> to convert from.
Returns
- T
The underlying typed value.
implicit operator EventSourceId<T>(string)
Implicitly convert from string to EventSourceId<T>,
parsing the string value into T.
public static implicit operator EventSourceId<T>(string value)
Parameters
Returns
- EventSourceId<T>
A converted EventSourceId<T>.
implicit operator EventSourceId<T>(T)
Implicitly convert from T to EventSourceId<T>.
public static implicit operator EventSourceId<T>(T value)
Parameters
valueTValue to convert from.
Returns
- EventSourceId<T>
A converted EventSourceId<T>.
operator !=(EventSourceId<T>?, EventSourceId<T>?)
public static bool operator !=(EventSourceId<T>? left, EventSourceId<T>? right)
Parameters
leftEventSourceId<T>rightEventSourceId<T>