Table of Contents

Class IdConverter2

Namespace
Geotab.Checkmate.Serialization
Assembly
Geotab.Checkmate.ObjectModel.dll

A class that contains the logic to convert an object to JSON.

public class IdConverter2 : BaseJsonConverter2<Id>
Inheritance
IdConverter2
Inherited Members

Constructors

IdConverter2()

public IdConverter2()

Methods

CanConvert(Type)

public override bool CanConvert(Type typeToConvert)

Parameters

typeToConvert Type

Returns

bool

IsId(in ReadOnlySpan<byte>)

Determines whether the specified value is identifier.

public static bool IsId(in ReadOnlySpan<byte> value)

Parameters

value ReadOnlySpan<byte>

The value.

Returns

bool

bool

IsId(string)

Determines whether the specified value is identifier.

public static bool IsId(string value)

Parameters

value string

The value.

Returns

bool

bool

Parse(in ReadOnlySpan<byte>)

Internal method to parse the string to Id for JSON serialization.

public static Id Parse(in ReadOnlySpan<byte> value)

Parameters

value ReadOnlySpan<byte>

The value.

Returns

Id

Id

Exceptions

ArgumentException

Invalid token: + value.

Parse(string)

Internal method to parse the string to Id for JSON serialization.

public static Id Parse(string value)

Parameters

value string

The value.

Returns

Id

Id

Exceptions

ArgumentException

Invalid token: + value.

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Read and convert the JSON to T.

public override Id Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters

reader Utf8JsonReader

The Utf8JsonReader to read from.

typeToConvert Type

The Type being converted.

options JsonSerializerOptions

The JsonSerializerOptions being used.

Returns

Id

The value that was converted.

Remarks

A converter may throw any Exception, but should throw JsonException when the JSON is invalid.

Write(Utf8JsonWriter, Id, bool)

Writes the provided Id using the provided Utf8JsonWriter. Can be written as a value or property name.

public static void Write(Utf8JsonWriter writer, Id value, bool asPropertyName)

Parameters

writer Utf8JsonWriter

The Utf8JsonWriter to write the Id to.

value Id

The Id to write to the Utf8JsonWriter.

asPropertyName bool

A bool indicating if the Id should be written as a property name or a value.

Write(Utf8JsonWriter, Id, JsonSerializerOptions)

Write the value as JSON.

public override void Write(Utf8JsonWriter writer, Id value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter

The Utf8JsonWriter to write to.

value Id

The value to convert.

options JsonSerializerOptions

The JsonSerializerOptions being used.

Remarks

A converter may throw any Exception, but should throw JsonException when the JSON cannot be created.