Class RequiredLong<TSelf>
- Namespace
- Trellis
- Assembly
- Trellis.Primitives.dll
Base class for creating strongly-typed long integer value objects. Provides a foundation for large identifiers, sequence numbers, and other domain concepts represented by long integers.
public abstract class RequiredLong<TSelf> : ScalarValueObject<TSelf, long>, IComparable<ValueObject>, IComparable, IEquatable<ValueObject>, IConvertible, IFormattable where TSelf : RequiredLong<TSelf>, IScalarValue<TSelf, long>
Type Parameters
TSelf
- Inheritance
-
ScalarValueObject<TSelf, long>RequiredLong<TSelf>
- Implements
- Inherited Members
- Extension Methods
Examples
Creating a strongly-typed long identifier:
public partial class TraceId : RequiredLong<TraceId> { }
var result = TraceId.TryCreate(123456789L);
Remarks
This class extends ScalarValueObject<TSelf, T> to provide a specialized base for long-based value objects
with automatic validation. When used with the partial keyword,
the PrimitiveValueObjectGenerator source generator automatically creates:
IScalarValue<TSelf, long>implementation for ASP.NET Core automatic validationTryCreate(long)- Factory method for longs (required by IScalarValue)TryCreate(long?, string?)- Factory method with validation and custom field nameTryCreate(string?, string?)- Factory method for parsing strings with validationIParsable<T>implementation (Parse,TryParse)- JSON serialization support via
ParsableJsonConverter<T> - Explicit cast operator from long
- OpenTelemetry activity tracing
Constructors
RequiredLong(long)
Initializes a new instance of the RequiredLong<TSelf> class with the specified long value.
protected RequiredLong(long value)
Parameters
valuelongThe long value.
See Also
ScalarValueObject<TSelf, T>
RequiredInt<TSelf>