Class ScalarValueModelBinderBase<TResult, TValue, TPrimitive>
- Namespace
- Trellis.Asp.ModelBinding
- Assembly
- Trellis.Asp.dll
Base model binder for scalar value types that handles primitive conversion,
validation via TryCreate, and error collection.
public abstract class ScalarValueModelBinderBase<TResult, TValue, TPrimitive> : IModelBinder where TValue : IScalarValue<TValue, TPrimitive> where TPrimitive : IComparable
Type Parameters
TResultThe result type of binding (e.g.,
TValueorMaybe<TValue>).TValueThe scalar value object type.
TPrimitiveThe underlying primitive type.
- Inheritance
-
ScalarValueModelBinderBase<TResult, TValue, TPrimitive>
- Implements
- Derived
- Inherited Members
- Extension Methods
Methods
BindModelAsync(ModelBindingContext)
Attempts to bind a model.
public Task BindModelAsync(ModelBindingContext bindingContext)
Parameters
bindingContextModelBindingContextThe ModelBindingContext.
Returns
- Task
A Task which will complete when the model binding process completes.
If model binding was successful, the Result should have IsModelSet set to
true.A model binder that completes successfully should set Result to a value returned from Success(object).
OnEmptyValue()
Returns the binding result when an empty string is provided.
Returns null to continue with normal conversion logic.
protected virtual ModelBindingResult? OnEmptyValue()
Returns
OnMissingValue()
Returns the binding result when no value is provided.
protected abstract ModelBindingResult OnMissingValue()
Returns
OnSuccess(TValue)
Wraps a successfully validated value object into the binding result.
protected abstract ModelBindingResult OnSuccess(TValue value)
Parameters
valueTValue