Skip to main content
Version: Preview (0.3.0-preview.205)

Class ValueObjectMvcExtensions

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

Wires value object support into an ASP.NET Core application.

public static class ValueObjectMvcExtensions

Inheritance​

object ← ValueObjectMvcExtensions

Inherited Members​

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

Methods​

AddValueObjectProblemDetails(ApiBehaviorOptions)​

Adds the stable error codes of the rejected value objects to the automatic 400 response.

public static ApiBehaviorOptions AddValueObjectProblemDetails(this ApiBehaviorOptions options)

Parameters​

options ApiBehaviorOptions

API behaviour options.

Returns​

ApiBehaviorOptions

The same options, so calls can be chained.

Remarks​

The framework's own ValidationProblemDetails response is kept as is, with an errorCodes extension added next to errors: the human-readable messages stay where clients expect them, and a client that wants to branch on a rule now has something stable to branch on.

AddValueObjects(MvcOptions)​

Binds value objects from the underlying value everywhere MVC reads text.

public static MvcOptions AddValueObjects(this MvcOptions options)

Parameters​

options MvcOptions

MVC options.

Returns​

MvcOptions

The same options, so calls can be chained.

Remarks​

The provider is inserted first so that it wins over the built-in simple-type and complex-type binders, which would otherwise try to bind a value object as an object with a Value property.

AddValueObjects(IMvcBuilder)​

Registers value object model binding and JSON serialization on an MVC builder.

public static IMvcBuilder AddValueObjects(this IMvcBuilder builder)

Parameters​

builder IMvcBuilder

MVC builder.

Returns​

IMvcBuilder

The same builder, so calls can be chained.