Class ExtensibleEnumConverterFactory
- Namespace
- Cloudflare.NET.Core.Json
- Assembly
- Cloudflare.NET.dll
A JSON converter factory that automatically creates converters for any type implementing IExtensibleEnum<TSelf>.
Register this factory with Converters to enable automatic serialization of all extensible enum types without individual converter attributes.
public class ExtensibleEnumConverterFactory : JsonConverterFactory
- Inheritance
-
ExtensibleEnumConverterFactory
- Inherited Members
Examples
var options = new JsonSerializerOptions();
options.Converters.Add(new ExtensibleEnumConverterFactory());
Remarks
This factory uses reflection to detect types implementing the extensible enum interface and creates the appropriate generic converter instance.
Methods
CanConvert(Type)
When overridden in a derived class, determines whether the converter instance can convert the specified object type.
public override bool CanConvert(Type typeToConvert)
Parameters
typeToConvertTypeThe type of the object to check whether it can be converted by this converter instance.
Returns
CreateConverter(Type, JsonSerializerOptions)
Creates a converter for a specified type.
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
Parameters
typeToConvertTypeThe type handled by the converter.
optionsJsonSerializerOptionsThe serialization options to use.
Returns
- JsonConverter
A converter for which
Tis compatible withtypeToConvert.