Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml Inheritance: System.EnumSyntax
Summary
Specifies how enumeration values are written.Usage
XmlEnumHandling is the type of XmlSerializerOptions.EnumHandling. It decides whether an enumeration value is written as the name of its member or as its number. The default is Name.
EnumHandling is Name.
View the complete sample on GitHub
Considerations
- The setting affects writing. It applies to enumeration members written as elements and as attributes.
- With
Name, a[Flags]value is written as the names of its flags separated by spaces, for exampleClass Struct. A value that has no name is written as its number. - A name that isn’t a member of the enumeration is an
XmlExceptionwhen read, with the messageThe value is not a valid enum member. - Names are more readable and survive a renumbering of the enumeration. Numbers survive a rename. Choose the form that matches how the type is expected to change.
- System.Text.Json writes enumerations as numbers by default and needs
JsonStringEnumConverterfor names. XmlEssentials writes names by default, asSystem.Xml.Serializationdoes.
Values
Related APIs
- CloudNimble.Text.Xml.XmlSerializerOptions
- CloudNimble.Text.Xml.XmlSerializer
- CloudNimble.Text.Xml.Serialization.XmlSourceGenerationOptionsAttribute