Skip to main content
Version: Preview (0.3.0-preview.205)

Class EntityIdPrefix

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

The rules a declared prefix must satisfy.

public static class EntityIdPrefix

Inheritance​

object ← EntityIdPrefix

Inherited Members​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks​

The generator enforces these at compile time through VO0015, so a malformed prefix never reaches a running application. They are restated here because the runtime factories are public and a hand-written identifier type can reach them without passing through the generator.

Fields​

MaxLength​

The greatest total length of a prefix, separators included.

public const int MaxLength = 16

Field Value​

int

MaxSegmentLength​

The greatest length of one segment.

public const int MaxSegmentLength = 8

Field Value​

int

Separator​

The separator between the prefix and the body, and between the segments of a multi-segment prefix.

public const char Separator = '_'

Field Value​

char

Methods​

IsValid(string?, out string?)​

Determines whether a prefix is usable, and says why when it is not.

public static bool IsValid(string? prefix, out string? error)

Parameters​

prefix string?

Prefix to check, without its trailing separator.

error string?

The rule that was broken, or null when the prefix is usable.

Returns​

bool

true when prefix is usable.

ThrowIfInvalid(string?, string)​

Throws when a prefix is unusable.

public static void ThrowIfInvalid(string? prefix, string parameterName)

Parameters​

prefix string?

Prefix to check.

parameterName string

Name of the argument being validated.

Exceptions​

ArgumentException

prefix breaks one of the rules.