Table of Contents

DiscreteIntervalJsonConverterFactory Class

Definition

Namespace
Bodu.Numerics.Serialization.Json
Assembly
Bodu.Numerics.Serialization.Json.dll
Package
Bodu.Numerics.Serialization.Json 1.3.0
Source
DiscreteIntervalJsonConverterFactory.cs

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

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

Remarks

Register this factory through AddNumericsJsonConverters(JsonSerializerOptions, NumericsJsonPolicy); the core DiscreteInterval<T> type carries no JsonConverterAttribute so that Bodu.Numerics stays serialization-agnostic.

Constructors

DiscreteIntervalJsonConverterFactory()

Initializes a new instance of the DiscreteIntervalJsonConverterFactory class configured for the Strict shape.

[RequiresDynamicCode("DiscreteIntervalJsonConverterFactory constructs a DiscreteIntervalJsonConverter<T> for each component type at run time, which native AOT cannot do without runtime code generation. Register DiscreteIntervalJsonConverter<T> for each component type instead.")]
public DiscreteIntervalJsonConverterFactory()

DiscreteIntervalJsonConverterFactory(NumericsJsonPolicy)

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

[RequiresDynamicCode("DiscreteIntervalJsonConverterFactory constructs a DiscreteIntervalJsonConverter<T> for each component type at run time, which native AOT cannot do without runtime code generation. Register DiscreteIntervalJsonConverter<T> for each component type instead.")]
public DiscreteIntervalJsonConverterFactory(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 DiscreteInterval<T> type; otherwise, false.

CreateConverter(Type, JsonSerializerOptions)

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

[UnconditionalSuppressMessage("Aot", "IL3050", Justification = "Every instance is created through a constructor annotated with RequiresDynamicCode, so the requirement is reported where the factory is created.")]
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)

Parameters

typeToConvert Type

The closed DiscreteInterval<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