TomlNumberEnumConverter<TEnum> Class
Definition
Produces a converter that serializes the enumeration TEnum as a TOML integer carrying its
underlying numeric value.
public sealed class TomlNumberEnumConverter<TEnum> : TomlConverterFactory where TEnum : struct, Enum
Type Parameters
TEnumThe enumeration type the produced converter handles.
- Inheritance
-
TomlNumberEnumConverter<TEnum>
- Inherited Members
- Extension Methods
Examples
public sealed class WorkItem
{
[Converter(typeof(TomlNumberEnumConverter<Priority>))]
public Priority Priority { get; set; }
}
// Priority.High (underlying value 2) serializes as: Priority = 2
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
TomlNumberEnumConverter()
Initializes a new instance of the TomlNumberEnumConverter<TEnum> class.
public TomlNumberEnumConverter()
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, TomlSerializerOptions)
Creates a converter for the specified type.
public override TomlConverter CreateConverter(Type typeToConvert, TomlSerializerOptions options)
Parameters
typeToConvertTypeThe closed type to create a converter for.
optionsTomlSerializerOptionsThe serializer options in effect.
Returns
- TomlConverter
A converter that handles
typeToConvert.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |