Class ValueObjectDescriptor
Namespace: AdCodicem.ValueObjects.Metadata
Assembly: AdCodicem.ValueObjects.Abstractions.dll
Runtime description of a value object type, used by the integrations that only know a
public sealed class ValueObjectDescriptor
Inheritance
object ← ValueObjectDescriptor
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
The delegates it exposes operate on boxed values, which is acceptable because every one of them is invoked during start-up work — building the EF Core model, generating an OpenAPI document, registering a Dapper type handler — never on a per-request path. Request paths go through the strongly typed generic APIs.
Descriptors are produced by
Properties
Create
Gets the validating factory. Throws
public Func<object?, object> Create { get; }
Property Value
CreateUnchecked
Gets the trusted-source factory, which performs neither normalization nor validation.
public Func<object?, object> CreateUnchecked { get; }
Property Value
Format
Gets the invariant text representation of a boxed value object.
public Func<object, string> Format { get; }
Property Value
GetValue
Gets the accessor returning the boxed underlying value of a boxed value object.
public Func<object, object?> GetValue { get; }
Property Value
Schema
Gets the declarative constraints of the value object.
public ValueObjectSchema Schema { get; }
Property Value
TryCreate
Gets the non-throwing validating factory.
public BoxedTryCreate TryCreate { get; }
Property Value
TryParse
Gets the non-throwing text parser.
public BoxedTryParse TryParse { get; }
Property Value
ValueObjectType
Gets the value object type.
public Type ValueObjectType { get; }
Property Value
ValueType
Gets the underlying value type.
public Type ValueType { get; }
Property Value
Methods
For<TSelf, TValue>(ValueObjectSchema)
Builds a descriptor for a value object, resolving every operation statically.
public static ValueObjectDescriptor For<TSelf, TValue>(ValueObjectSchema schema) where TSelf : struct, IValueObject<TSelf, TValue>
Parameters
schema ValueObjectSchema
Declarative constraints of the value object.
Returns
The descriptor.
Type Parameters
TSelf
Value object type.
TValue
Underlying value type.