Class IPAddressConverter
- Namespace
- VpnHood.Net.Toolkit.Converters
- Assembly
- VpnHood.Net.Toolkit.dll
Converts an IPAddress to and from its text form, such as 192.168.0.1 or ::1.
public class IPAddressConverter : JsonConverter<IPAddress>
- Inheritance
-
IPAddressConverter
- Inherited Members
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to type IPAddress.
public override IPAddress Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe reader.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Returns
- IPAddress
The converted value.
Exceptions
- FormatException
The value is not an IP address.
- InvalidOperationException
The value is not a string.
Write(Utf8JsonWriter, IPAddress, JsonSerializerOptions)
Writes a specified value as JSON.
public override void Write(Utf8JsonWriter writer, IPAddress value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write to.
valueIPAddressThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.