Class PortRangeConverter
Converts a port range to and from its text form, such as 1000-2000.
public class PortRangeConverter : JsonConverter<PortRange>
- Inheritance
-
PortRangeConverter
- Inherited Members
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to type PortRange.
public override PortRange Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe reader.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Returns
- PortRange
The converted value.
Exceptions
- FormatException
The value is not a port range.
- ArgumentOutOfRangeException
A bound is out of range.
- InvalidOperationException
The reader's token is neither a string, a property name, nor a null.
Write(Utf8JsonWriter, PortRange, JsonSerializerOptions)
Writes a specified value as JSON.
public override void Write(Utf8JsonWriter writer, PortRange value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write to.
valuePortRangeThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.