BencodeNumberEnumConverter<TEnum> Class
Definition
- Namespace
- Bodu.Text.Bencode.Serialization
- Assembly
- Bodu.Text.Bencode.dll
- Package
- Bodu.Text.Bencode 1.0.0
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
TEnumThe 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
typeToConvertTypeThe type to test.
Returns
CreateConverter(Type, BencodeSerializerOptions)
Creates a converter for the specified type.
public override BencodeConverter CreateConverter(Type typeToConvert, BencodeSerializerOptions options)
Parameters
typeToConvertTypeThe closed type to create a converter for.
optionsBencodeSerializerOptionsThe serializer options in effect.
Returns
- BencodeConverter
A converter that handles
typeToConvert.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |