Noda Time
Show / Hide Table of Contents

Class DelegatingConverterBase<T>

Converter which does nothing but delegate to another one for all operations.
Since 1.0.x
Availability net6.0, netstandard2.0
Inheritance
object
JsonConverter
JsonConverter<T>
DelegatingConverterBase<T>
Inherited Members
JsonConverter<T>.ReadAsPropertyName(ref Utf8JsonReader, Type, JsonSerializerOptions)
JsonConverter<T>.WriteAsPropertyName(Utf8JsonWriter, T, JsonSerializerOptions)
JsonConverter<T>.HandleNull
JsonConverter<T>.Type
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: NodaTime.Serialization.SystemTextJson
Assembly: NodaTime.Serialization.SystemTextJson.dll
Syntax
public abstract class DelegatingConverterBase<T> : JsonConverter<T>
Type Parameters
Name Description
T The type of object or value handled by the converter.
Remarks
Nothing in this class is specific to Noda Time. Its purpose is to make it easy to reuse other converter instances with LocalDate, which can only identify a converter by type.
Examples

If you had some JsonConverterAttribute properties which needed one converter, but others that needed another, you might want to have different types implementing those converters. Each type would just derive from this, passing the right converter into the base constructor.

public sealed class ShortDateConverter : DelegatingConverterBase
{
    public ShortDateConverter() : base(NodaConverters.LocalDateConverter) {}
}

Constructors

DelegatingConverterBase(JsonConverter<T>)

Constructs a converter delegating to original.
Since 1.0.x
Availability net6.0, netstandard2.0
Declaration
protected DelegatingConverterBase(JsonConverter<T> original)
Parameters
Type Name Description
JsonConverter<T> original The converter to delegate to. Must not be null.

Methods

CanConvert(Type)

Determines whether the specified type can be converted.
Since 1.0.x
Availability net6.0, netstandard2.0
Declaration
public override bool CanConvert(Type objectType)
Parameters
Type Name Description
Type objectType
Returns
Type Description
bool true if the type can be converted; otherwise, false.
Overrides
JsonConverter<T>.CanConvert(Type)

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads and converts the JSON to type T.
Since 1.0.x
Availability net6.0, netstandard2.0
Declaration
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
Type Name Description
Utf8JsonReader reader The reader.
Type typeToConvert The type to convert.
JsonSerializerOptions options An object that specifies serialization options to use.
Returns
Type Description
T The converted value.
Overrides
JsonConverter<T>.Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Write(Utf8JsonWriter, T, JsonSerializerOptions)

Writes a specified value as JSON.
Since 1.0.x
Availability net6.0, netstandard2.0
Declaration
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
Parameters
Type Name Description
Utf8JsonWriter writer The writer to write to.
T value The value to convert to JSON.
JsonSerializerOptions options An object that specifies serialization options to use.
Overrides
JsonConverter<T>.Write(Utf8JsonWriter, T, JsonSerializerOptions)
In this article
Back to top Generated by DocFX