Class ValueObjectIds
Namespace: AdCodicem.ValueObjects.Identifiers
Assembly: AdCodicem.ValueObjects.Identifiers.dll
The clock and the entropy source that New() reads.
public static class ValueObjectIds
Inheritance
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
Two layers.
The scope is not a convenience: the test suites run in parallel, and a settable static alone would let two
tests racing to substitute the clock corrupt one another. The failure that produces is intermittent and
lands in whichever test happens to observe it, which is the most expensive kind to diagnose. An
Properties
Entropy
Gets the entropy source in effect, preferring the innermost open scope.
public static IdEntropySource Entropy { get; }
Property Value
TimeProvider
Gets the clock in effect, preferring the innermost open scope.
public static TimeProvider TimeProvider { get; }
Property Value
Methods
Configure(TimeProvider?, IdEntropySource?)
Replaces the process-wide default.
public static void Configure(TimeProvider? timeProvider = null, IdEntropySource? entropy = null)
Parameters
timeProvider TimeProvider?
Clock to use, or null to keep the current one.
entropy IdEntropySource?
Entropy source to use, or null to keep the current one.
Remarks
Intended to be called once, during start-up, before anything generates an identifier. It is not
synchronized against concurrent generation: substituting the clock while requests are in flight is a
test concern, and
Use(TimeProvider?, IdEntropySource?)
Opens a scope that overrides the default for the current execution flow.
public static IDisposable Use(TimeProvider? timeProvider = null, IdEntropySource? entropy = null)
Parameters
timeProvider TimeProvider?
Clock to use, or null to inherit the enclosing one.
entropy IdEntropySource?
Entropy source to use, or null to inherit the enclosing one.
Returns
A handle that restores the enclosing state when disposed.
Examples
using (ValueObjectIds.Use(fakeClock, deterministicBytes))
{
var id = AccountId.New();
}