Class EntityIdRegistry
Namespace: AdCodicem.ValueObjects.Identifiers
Assembly: AdCodicem.ValueObjects.Identifiers.dll
Process-wide index from a prefix to the identifier type that claims it.
public static class EntityIdRegistry
Inheritance
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
The generator emits a registration per assembly alongside the value object one, so the common case is a lock-free dictionary hit with no reflection and no dynamic code — usable under native AOT.
Two types claiming the same prefix is refused rather than tolerated. Within one compilation the generator
catches it as VO0016; across assemblies only the second registration can notice, and letting it win
silently would make
Methods
GetRegistered()
Gets the identifier types registered so far.
public static IReadOnlyCollection<EntityIdDescriptor> GetRegistered()
Returns
IReadOnlyCollection<EntityIdDescriptor>
A snapshot of the registered descriptors.
Register<TSelf>()
Registers an identifier type without reflection.
public static void Register<TSelf>() where TSelf : struct, IEntityId<TSelf>
Type Parameters
TSelf
Identifier type.
Exceptions
Another type already claims the same prefix.
Register(EntityIdDescriptor)
Registers a descriptor.
public static void Register(EntityIdDescriptor descriptor)
Parameters
descriptor EntityIdDescriptor
Descriptor to register.
Exceptions
descriptor is null.
Another type already claims the same prefix.
TryGetByPrefix(string, out EntityIdDescriptor?)
Looks up the type claiming a prefix.
public static bool TryGetByPrefix(string prefix, out EntityIdDescriptor? descriptor)
Parameters
prefix string
Prefix, without its trailing separator.
descriptor EntityIdDescriptor?
The descriptor when found.
Returns
true when a type claims prefix.
TryResolve(ReadOnlySpan<char>, out EntityIdDescriptor?)
Resolves the identifier type a text belongs to, from its prefix.
public static bool TryResolve(ReadOnlySpan<char> text, out EntityIdDescriptor? descriptor)
Parameters
text ReadOnlySpan<char>
Candidate identifier.
descriptor EntityIdDescriptor?
The descriptor when the prefix is claimed.
Returns
true when the text carries a registered prefix.
Remarks
A prefix may itself hold separators, so the split cannot be taken at the first one. The body length is fixed per granularity instead, which makes the prefix boundary computable and bounds resolution to one lookup per granularity rather than a scan of the registry.