Skip to main content
Version: 0.3.x (0.3.0)

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​

IModelBinderProvider

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 (), never at run time with . The registry still describes by reflection a value object nothing registered, one written by hand or a construction of a generic one, the first time it is asked for it.

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 , and hands it the header alone.

Methods​

GetBinder(ModelBinderProviderContext)​

Creates a based on .

public IModelBinder? GetBinder(ModelBinderProviderContext context)

Parameters​

context ModelBinderProviderContext

The .

Returns​

IModelBinder?

An .