Table of Contents

ComplexJsonConverterFactory Class

Definition

Namespace
Bodu.Numerics.Serialization.Json
Assembly
Bodu.Numerics.Serialization.Json.dll
Package
Bodu.Numerics.Serialization.Json 1.0.0
Source
ComplexJsonConverterFactory.cs

Creates ComplexJsonConverter<T> instances for closed Complex<T> types, applying a configurable NumericsJsonPolicy to every closed converter the factory produces.

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

Remarks

The core Complex<T> type carries no JsonConverterAttribute so that Bodu.Numerics stays serialization-agnostic; register this factory through AddNumericsJsonConverters(JsonSerializerOptions, NumericsJsonPolicy) (which registers a coherent set for every numeric type) or add it directly to Converters.

Constructors

ComplexJsonConverterFactory()

Initializes a new instance of the ComplexJsonConverterFactory class configured for the Strict shape. Invoked by JsonConverterAttribute.

public ComplexJsonConverterFactory()

ComplexJsonConverterFactory(NumericsJsonPolicy)

Initializes a new instance of the ComplexJsonConverterFactory class configured for the supplied policy.

public ComplexJsonConverterFactory(NumericsJsonPolicy policy)

Parameters

policy NumericsJsonPolicy

The policy applied to every closed converter the factory produces.

Exceptions

ArgumentOutOfRangeException

policy is not a defined NumericsJsonPolicy value.

Methods

CanConvert(Type)

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

public override bool CanConvert(Type typeToConvert)

Parameters

typeToConvert Type

The candidate type.

Returns

bool

true if typeToConvert is a closed Complex<T> type; otherwise, false.

CreateConverter(Type, JsonSerializerOptions)

Creates a converter for the specified closed Complex<T> type.

[UnconditionalSuppressMessage("Aot", "IL3050", Justification = "Reached only through reflection-based JSON serialization, whose public entry points carry the RequiresDynamicCode annotation.")]
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)

Parameters

typeToConvert Type

The closed Complex<T> type to convert.

options JsonSerializerOptions

The serializer options in effect.

Returns

JsonConverter

A converter for typeToConvert.

Exceptions

ArgumentNullException

Thrown when typeToConvert is null.

Applies to

ProductVersions
.NET8, 10