Class ConstrainedValue<T>
Base class for creating types that validate their value against runtime constraints.
public abstract class ConstrainedValue<T>
Type Parameters
TThe wrapped value type.
- Inheritance
-
ConstrainedValue<T>
- Inherited Members
- Extension Methods
Constructors
ConstrainedValue(T)
Initialises a new instance of the ConstrainedValue<T> class.
protected ConstrainedValue(T value)
Parameters
valueTThe value to validate.
Properties
Value
Gets the validated value.
public T Value { get; }
Property Value
- T
Methods
CheckValue(T)
Validates the provided value according to the derived class rules.
protected abstract void CheckValue(T value)
Parameters
valueTThe value to validate.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Operators
implicit operator T(ConstrainedValue<T>)
Converts a ConstrainedValue<T> to its underlying T value.
public static implicit operator T(ConstrainedValue<T> constrainedValue)
Parameters
constrainedValueConstrainedValue<T>The constrained value to unwrap.
Returns
- T