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
typeToConvertType
Returns
IsId(in ReadOnlySpan<byte>)
Determines whether the specified value is identifier.
public static bool IsId(in ReadOnlySpan<byte> value)
Parameters
valueReadOnlySpan<byte>The value.
Returns
IsId(string)
Determines whether the specified value is identifier.
public static bool IsId(string value)
Parameters
valuestringThe 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
valueReadOnlySpan<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
valuestringThe 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
readerUtf8JsonReaderThe Utf8JsonReader to read from.
typeToConvertTypeThe Type being converted.
optionsJsonSerializerOptionsThe 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
writerUtf8JsonWriterThe Utf8JsonWriter to write the Id to.
valueIdThe Id to write to the Utf8JsonWriter.
asPropertyNameboolA 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
writerUtf8JsonWriterThe Utf8JsonWriter to write to.
valueIdThe value to convert.
optionsJsonSerializerOptionsThe JsonSerializerOptions being used.
Remarks
A converter may throw any Exception, but should throw