Noda Time
Show / Hide Table of Contents

Class NodaPatternConverter<T>

A JSON converter for types which can be represented by a single string value, parsed or formatted from an IPattern<T>.
Since 1.0.x
Availability net6.0, netstandard2.0
Inheritance
object
JsonConverter
JsonConverter<T>
NodaConverterBase<T>
NodaPatternConverter<T>
Inherited Members
NodaConverterBase<T>.CanConvert(Type)
NodaConverterBase<T>.Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
NodaConverterBase<T>.ReadAsPropertyName(ref Utf8JsonReader, Type, JsonSerializerOptions)
NodaConverterBase<T>.Write(Utf8JsonWriter, T, JsonSerializerOptions)
NodaConverterBase<T>.WriteAsPropertyName(Utf8JsonWriter, T, JsonSerializerOptions)
JsonConverter<T>.HandleNull
JsonConverter<T>.Type
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: NodaTime.Serialization.SystemTextJson
Assembly: NodaTime.Serialization.SystemTextJson.dll
Syntax
public sealed class NodaPatternConverter<T> : NodaConverterBase<T>
Type Parameters
Name Description
T The type to convert to/from JSON.

Constructors

NodaPatternConverter(IPattern<T>)

Creates a new instance with a pattern and no validator.
Since 1.0.x
Availability net6.0, netstandard2.0
Declaration
public NodaPatternConverter(IPattern<T> pattern)
Parameters
Type Name Description
IPattern<T> pattern The pattern to use for parsing and formatting.
Exceptions
Type Condition
ArgumentNullException pattern is null.

NodaPatternConverter(IPattern<T>, Action<T>)

Creates a new instance with a pattern and an optional validator. The validator will be called before each value is written, and may throw an exception to indicate that the value cannot be serialized.
Since 1.0.x
Availability net6.0, netstandard2.0
Declaration
public NodaPatternConverter(IPattern<T> pattern, Action<T> validator)
Parameters
Type Name Description
IPattern<T> pattern The pattern to use for parsing and formatting.
Action<T> validator The validator to call before writing values. May be null, indicating that no validation is required.
Exceptions
Type Condition
ArgumentNullException pattern is null.

Methods

ReadJsonImpl(ref Utf8JsonReader, JsonSerializerOptions)

Implemented by concrete subclasses, this performs the final conversion from a non-null JSON value to a value of type T.
Since 1.0.x
Availability net6.0, netstandard2.0
Declaration
protected override T ReadJsonImpl(ref Utf8JsonReader reader, JsonSerializerOptions options)
Parameters
Type Name Description
Utf8JsonReader reader The JSON reader to pull data from
JsonSerializerOptions options The serializer options to use for nested serialization
Returns
Type Description
T The deserialized value of type T.
Overrides
NodaConverterBase<T>.ReadJsonImpl(ref Utf8JsonReader, JsonSerializerOptions)

WriteJsonImpl(Utf8JsonWriter, T, JsonSerializerOptions)

Writes the formatted value to the writer.
Since 1.0.x
Availability net6.0, netstandard2.0
Declaration
protected override void WriteJsonImpl(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
Parameters
Type Name Description
Utf8JsonWriter writer The writer to write JSON data to
T value The value to serialize
JsonSerializerOptions options The serializer options to use for nested serialization
Overrides
NodaConverterBase<T>.WriteJsonImpl(Utf8JsonWriter, T, JsonSerializerOptions)

WriteJsonPropertyNameImpl(Utf8JsonWriter, T, JsonSerializerOptions)

Writes the formatted value to the writer.
Since 3.2.x
Availability net6.0, netstandard2.0
Declaration
protected override void WriteJsonPropertyNameImpl(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
Parameters
Type Name Description
Utf8JsonWriter writer The writer to write JSON data to.
T value The value to serialize.
JsonSerializerOptions options The serialization options to use for nested serialization.
Overrides
NodaConverterBase<T>.WriteJsonPropertyNameImpl(Utf8JsonWriter, T, JsonSerializerOptions)
In this article
Back to top Generated by DocFX