Table of Contents

Class MaybeScalarValueJsonConverterFactory

Namespace
Trellis.Asp.Validation
Assembly
Trellis.Asp.dll

Factory for creating MaybeScalarValueJsonConverter<TValue, TPrimitive> instances for Maybe<T> properties where T implements IScalarValue<TSelf, TPrimitive>.

public sealed class MaybeScalarValueJsonConverterFactory : JsonConverterFactory
Inheritance
MaybeScalarValueJsonConverterFactory
Inherited Members
Extension Methods

Remarks

This factory is registered with JsonSerializerOptions and automatically creates converters for Maybe<T> types wrapping scalar value objects.

It complements ValidatingJsonConverterFactory which handles direct IScalarValue<TSelf, TPrimitive> properties.

Methods

CanConvert(Type)

Determines whether this factory can create a converter for the specified type.

[UnconditionalSuppressMessage("Trimming", "IL2067", Justification = "Value object types are preserved by JSON serialization infrastructure")]
public override bool CanConvert(Type typeToConvert)

Parameters

typeToConvert Type

The type to check.

Returns

bool

true if the type is Maybe<T> where T implements IScalarValue<TSelf, TPrimitive>.

CreateConverter(Type, JsonSerializerOptions)

Creates a converter for the specified Maybe<T> type.

[UnconditionalSuppressMessage("Trimming", "IL2067", Justification = "Value object types are preserved by JSON serialization infrastructure")]
[UnconditionalSuppressMessage("Trimming", "IL2070", Justification = "Value object types are preserved by JSON serialization infrastructure")]
[UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "Inner type of Maybe<T> is preserved by JSON serialization infrastructure")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "JsonConverterFactory is not compatible with Native AOT")]
public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)

Parameters

typeToConvert Type

The Maybe<T> type.

options JsonSerializerOptions

The serializer options.

Returns

JsonConverter

A MaybeScalarValueJsonConverter<TValue, TPrimitive> for the type.