Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml.Serialization Inheritance: System.EnumSyntax
Summary
Specifies how a derived type that has not been explicitly declared for polymorphic serialization is handled when a polymorphic type is read or written.Usage
XmlUnknownDerivedTypeHandling is the type of XmlPolymorphicAttribute.UnknownDerivedTypeHandling. It decides what the serializer does with a runtime type that the base type doesn’t declare with [XmlDerivedType<T>], and with a discriminator in a document that names no declared type.
With the default, serializing a
Catalog that holds an undeclared Ebook fails:
FallBackToNearestAncestor, see Handle a type that isn’t declared and the polymorphism sample.
Considerations
- A fallback loses data. The members that only the undeclared type has are not written, and the document reads back as the type it was written as.
- When reading, the discriminator applies to
XmlDiscriminatorPlacement.AttributeandXmlDiscriminatorPlacement.XsiType. WithElementName, an element whose name isn’t declared never reaches this setting: inside an object it is content that no member maps, and at the document root it fails the root name check. - An element with no discriminator at all is read as the declared base type in every mode.
- The values have the same names as
JsonUnknownDerivedTypeHandlingin System.Text.Json.
Values
Related APIs
- CloudNimble.Text.Xml.Serialization.XmlPolymorphicAttribute
- CloudNimble.Text.Xml.Serialization.XmlDerivedTypeAttribute
- CloudNimble.Text.Xml.Serialization.XmlUnmappedMemberHandling
- CloudNimble.Text.Xml.XmlDiscriminatorPlacement