Class ValueObjectInputConverter
Namespace: AdCodicem.ValueObjects.AzureFunctions
Assembly: AdCodicem.ValueObjects.AzureFunctions.dll
Binds a value object from the text of a route value, a query value or other binding data, through its
TryParse.
public sealed class ValueObjectInputConverter : IInputConverter
Inheritance
object ← ValueObjectInputConverter
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
The isolated worker reads no [TypeConverter]: without this converter, the text of a value object falls through
to the worker's JSON conversion, which refuses a valid Guid, string or DateOnly and fails every
such invocation. HttpRequest and an HttpRequestData alone.
It reads a parameter whose type, TryParse refuses. Empty text is parsed too, and refused by the type's
own rule. A parameter with no binding data is left to the worker, which binds null to a nullable
value object and its default value to an optional one, and fails a required one itself. A parameter carrying an input
or trigger binding attribute is left to that binding and to the worker's serializer, which honours the generated JSON
converter: naming this converter on the parameter with [InputConverter(typeof(ValueObjectInputConverter))]
reads a raw-text payload instead, and one that names another converter is left to it.
A refusal is FunctionInputConverterException it throws, which is why the message carries the code.
A generated value object registers itself; a value object written by hand and a construction of a generic one are described by reflection where the runtime supports dynamic code, and otherwise once registered by hand. Only the types described are kept, so that one registered after a first miss is read from then on.
Methods
ConvertAsync(ConverterContext)
Parses the text the host bound to the parameter, or leaves the parameter to the next converter.
public ValueTask<ConversionResult> ConvertAsync(ConverterContext context)
Parameters
context ConverterContext
The parameter's conversion context.
Returns
The value object, a failure carrying the rule's code, or
Exceptions
context is null.