Class ValueObjectModelBinderProvider
Namespace: AdCodicem.ValueObjects.AspNetCore.ModelBinding
Assembly: AdCodicem.ValueObjects.AspNetCore.dll
Supplies the model binder of any value object.
public sealed class ValueObjectModelBinderProvider : IModelBinderProvider
Inheritance
object ← ValueObjectModelBinderProvider
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
Providers are consulted once per action parameter while the application starts, so closing the generic
binder over the concrete types here costs nothing per request. The instances are cached anyway, by each provider,
because MVC creates metadata for the same type in many places. Each binder reads the messages of its provider, which
AddValueObjects(messages => …) configures, when it refuses a value.
Each binder is closed over its value object at compile time, through the type arguments the descriptor hands back
to a visitor (
A greedy binding source is declined: a header ([FromHeader]), the body ([FromBody]), the services
([FromServices]) or a binder the application names ([ModelBinder(typeof(…))]). MVC binds each through a
provider of its own, which this one, inserted first, would otherwise shadow, and does not narrow the value providers
to a greedy source, so the binder would read a route, query or form value of the same name instead. MVC's header
binder asks for this binder again, under
Methods
GetBinder(ModelBinderProviderContext)
Creates a
public IModelBinder? GetBinder(ModelBinderProviderContext context)
Parameters
context ModelBinderProviderContext
The
Returns
An