Skip to main content

Class ValueObjectModelBinder<TSelf, TValue>

Namespace: AdCodicem.ValueObjects.AspNetCore.ModelBinding
Assembly: AdCodicem.ValueObjects.AspNetCore.dll

Binds a value object from the raw text of a route segment, query string value, header or form field.

public sealed class ValueObjectModelBinder<TSelf, TValue> : IModelBinder where TSelf : struct, IValueObject<TSelf, TValue>

Type Parameters

TSelf

Value object type.

TValue

Underlying value type.

Inheritance

objectValueObjectModelBinder<TSelf, TValue>

Implements

IModelBinder

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks

The binder is closed over the concrete value object type, so binding costs one TryParse and nothing else: no reflection, no TypeDescriptor lookup, and no exception on the rejection path. The violated rule travels with the model error so that can put its stable code in the response body.

Methods

BindModelAsync(ModelBindingContext)

Attempts to bind a model.

public Task BindModelAsync(ModelBindingContext bindingContext)

Parameters

bindingContext ModelBindingContext

The .

Returns

Task

A which will complete when the model binding process completes.

If model binding was successful, the should have set to true.

A model binder that completes successfully should set to a value returned from .