Noda Time
Show / Hide Table of Contents

Class DelegatingConverterBase

Converter which does nothing but delegate to another one for all operations.
Since 2.0.x
Availability netstandard2.0
Inheritance
object
JsonConverter
DelegatingConverterBase
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: NodaTime.Serialization.JsonNet
Assembly: NodaTime.Serialization.JsonNet.dll
Syntax
public abstract class DelegatingConverterBase : JsonConverter
Remarks
Nothing in this class is specific to Noda Time. Its purpose is to make it easy to reuse other converter instances with JsonConverterAttribute, which can only identify a converter by type.
Examples

If you had some LocalDate 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)

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

Properties

CanRead

Gets a value indicating whether this JsonConverter can read JSON.
Since 2.0.x
Availability netstandard2.0
Declaration
public override bool CanRead { get; }
Property Value
Type Description
bool true if this JsonConverter can read JSON; otherwise, false.
Overrides
Newtonsoft.Json.JsonConverter.CanRead

CanWrite

Gets a value indicating whether this JsonConverter can write JSON.
Since 2.0.x
Availability netstandard2.0
Declaration
public override bool CanWrite { get; }
Property Value
Type Description
bool true if this JsonConverter can write JSON; otherwise, false.
Overrides
Newtonsoft.Json.JsonConverter.CanWrite

Methods

CanConvert(Type)

Determines whether this instance can convert the specified object type.
Since 2.0.x
Availability netstandard2.0
Declaration
public override bool CanConvert(Type objectType)
Parameters
Type Name Description
Type objectType Type of the object.
Returns
Type Description
bool true if this instance can convert the specified object type; otherwise, false.
Overrides
JsonConverter.CanConvert(Type)

ReadJson(JsonReader, Type, object, JsonSerializer)

Reads the JSON representation of the object.
Since 2.0.x
Availability netstandard2.0
Declaration
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
Parameters
Type Name Description
JsonReader reader The JsonReader to read from.
Type objectType Type of the object.
object existingValue The existing value of object being read.
JsonSerializer serializer The calling serializer.
Returns
Type Description
object The object value.
Overrides
JsonConverter.ReadJson(JsonReader, Type, object, JsonSerializer)

WriteJson(JsonWriter, object, JsonSerializer)

Writes the JSON representation of the object.
Since 2.0.x
Availability netstandard2.0
Declaration
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
Parameters
Type Name Description
JsonWriter writer The JsonWriter to write to.
object value The value.
JsonSerializer serializer The calling serializer.
Overrides
JsonConverter.WriteJson(JsonWriter, object, JsonSerializer)
In this article
Back to top Generated by DocFX