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
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
IsId(string)
Determines whether the specified value is identifier.
public static bool IsId(string value)
Parameters
value
stringThe value.
Returns
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
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
stringThe value.
Returns
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
Utf8JsonReaderThe Utf8JsonReader to read from.
typeToConvert
TypeThe Type being converted.
options
JsonSerializerOptionsThe JsonSerializerOptions being used.
Returns
- Id
The value that was converted.
Remarks
A converter may throw any Exception, but should throw
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
Utf8JsonWriterThe Utf8JsonWriter to write the Id to.
value
IdThe Id to write to the Utf8JsonWriter.
asPropertyName
boolA 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
Utf8JsonWriterThe Utf8JsonWriter to write to.
value
IdThe value to convert.
options
JsonSerializerOptionsThe JsonSerializerOptions being used.
Remarks
A converter may throw any Exception, but should throw