Class VersionConverter
- Namespace
- VpnHood.Net.Toolkit.Converters
- Assembly
- VpnHood.Net.Toolkit.dll
Converts a Version to and from its text form, such as 1.2.3.4.
public class VersionConverter : JsonConverter<Version>
- Inheritance
-
VersionConverter
- Inherited Members
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to type Version.
public override Version Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe reader.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Returns
- Version
The converted value.
Exceptions
- ArgumentException
The text has fewer than two or more than four parts.
- ArgumentOutOfRangeException
A part is negative.
- FormatException
A part is not a number.
- OverflowException
A part is too large.
- InvalidOperationException
The value is not a string.
Write(Utf8JsonWriter, Version, JsonSerializerOptions)
Writes a specified value as JSON.
public override void Write(Utf8JsonWriter writer, Version value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write to.
valueVersionThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.