Table of Contents

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

reader Utf8JsonReader

The reader.

typeToConvert Type

The type to convert.

options JsonSerializerOptions

An 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

writer Utf8JsonWriter

The writer to write to.

value IPAddress

The value to convert to JSON.

options JsonSerializerOptions

An object that specifies serialization options to use.