Skip to main content

Interface IEntityId<TSelf>

Namespace: AdCodicem.ValueObjects.Identifiers
Assembly: AdCodicem.ValueObjects.Identifiers.dll

The full contract of a public entity identifier.

[SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "New() is the name every caller reaches for, and the alternatives all stutter against the type name. The rule guards Visual Basic consumers, who would write New[](); that trade is worth making for the member domain code touches most.")]
public interface IEntityId<TSelf> : IEntityId, IValueObject<TSelf, string>, IValueObject<string>, IValueObject, IEquatable<TSelf>, IComparable<TSelf>, IComparable, ISpanParsable<TSelf>, IParsable<TSelf>, ISpanFormattable, IFormattable where TSelf : struct, IEntityId<TSelf>

Type Parameters

TSelf

The identifier type itself.

Implements

IEntityId, IValueObject<TSelf, string>, IValueObject<string>, IValueObject, IEquatable<TSelf>, IComparable<TSelf>, IComparable, ISpanParsable<TSelf>, IParsable<TSelf>, ISpanFormattable, IFormattable

Remarks

Implementations are produced by the source generator from . Everything the contract adds over is static, so a caller holding only a type parameter can mint identifiers without reflection and without a factory to inject.

Properties

Granularity

Gets the width of the time bucket heading the body.

public static abstract IdGranularity Granularity { get; }

Property Value

IdGranularity

Length

Gets the exact length of an identifier of this type, which is also the width of its database column.

public static abstract int Length { get; }

Property Value

int

Prefix

Gets the prefix identifiers of this type carry, without its trailing separator.

public static abstract string Prefix { get; }

Property Value

string

Methods

New()

Mints a new identifier from the ambient clock and entropy source.

public static abstract TSelf New()

Returns

TSelf

A fresh identifier, canonical and valid by construction.

Remarks

Both sources resolve through , so a test can substitute them for the current execution flow without an injected factory reaching every aggregate that creates an entity.

New(TimeProvider, IdEntropySource)

Mints a new identifier from explicit sources.

public static abstract TSelf New(TimeProvider timeProvider, IdEntropySource entropy)

Parameters

timeProvider TimeProvider

Clock supplying the time bucket.

entropy IdEntropySource

Source of the random part.

Returns

TSelf

A fresh identifier, canonical and valid by construction.