Table of Contents

BencodeNumberEnumConverter<TEnum> Class

Definition

Namespace
Bodu.Text.Bencode.Serialization
Assembly
Bodu.Text.Bencode.dll
Package
Bodu.Text.Bencode 1.0.0
Source
NumberEnumConverter{T}.cs

Produces a converter that serializes the enumeration TEnum as a Bencode integer carrying its underlying numeric value.

public sealed class BencodeNumberEnumConverter<TEnum> : BencodeConverterFactory where TEnum : struct, Enum

Type Parameters

TEnum

The enumeration type the produced converter handles.

Inheritance
BencodeNumberEnumConverter<TEnum>
Inherited Members
Extension Methods

Examples

public sealed class WorkItem
{
    [Converter(typeof(BencodeNumberEnumConverter<Priority>))]
    public Priority Priority { get; set; }
}

// Priority.High (underlying value 2) serializes as the integer i2e.

Remarks

Reference the factory from a ConverterAttribute on a member, property, or the enumeration itself, or register it on Converters. It exposes a public parameterless constructor so it can be used through the converter attribute.

Constructors

BencodeNumberEnumConverter()

Initializes a new instance of the BencodeNumberEnumConverter<TEnum> class.

public BencodeNumberEnumConverter()

Methods

CanConvert(Type)

Determines whether the converter can convert the specified type.

public override bool CanConvert(Type typeToConvert)

Parameters

typeToConvert Type

The type to test.

Returns

bool

true when the converter handles typeToConvert; otherwise false.

CreateConverter(Type, BencodeSerializerOptions)

Creates a converter for the specified type.

public override BencodeConverter CreateConverter(Type typeToConvert, BencodeSerializerOptions options)

Parameters

typeToConvert Type

The closed type to create a converter for.

options BencodeSerializerOptions

The serializer options in effect.

Returns

BencodeConverter

A converter that handles typeToConvert.

Applies to

ProductVersions
.NET8, 10