Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml Inheritance: System.EnumSyntax
Summary
Specifies where a polymorphic type discriminator is written.Usage
XmlDiscriminatorPlacement is the type of XmlPolymorphicAttribute.DiscriminatorPlacement. It decides how a document says which derived type an element holds.
The following base type identifies its derived types with a
kind attribute:
Checkout object whose Payment member holds a CardPayment is written as follows:
Considerations
ElementNamechanges the name of the element, so it suits a list or a member whose element name isn’t fixed by a schema. An object of the base type itself keeps the member’s own element name.- Under every placement, a value whose type is the declared type of the member, the item or the document element is written with no discriminator, even when that declared type is itself one of the derived types. Only a type below the declared type is identified. With
AttributeorXsiType, and for the items of a wrapped collection, a discriminator that names a type that isn’t the declared type or below it throws anXmlException:The element identifies the type '...', which is not a '...'.WithElementName, an element named for such a type isn’t an element of the member at all: it is content that no member maps, skipped by default and an error underXmlUnmappedMemberHandling.Disallow. AttributerequiresXmlPolymorphicAttribute.TypeDiscriminatorPropertyName. Without it, the serializer throwsNotSupportedExceptionwhen it builds the type’s metadata. The attribute is in no namespace.XsiTypewrites the discriminator string as the value ofxsi:type, with no namespace prefix inside the value. It matches the attribute thatSystem.Xml.Serializationwrites, but the serializer doesn’t resolve the value as a schema type name.- With
AttributeandXsiType, the discriminator can be anywhere in the start tag. WithElementName, an element whose name isn’t declared is treated as content that no member maps. - The placement is set for each base type, on its
[XmlPolymorphic]attribute.XmlSerializerOptionshas no property for it.
Values
Related APIs
- CloudNimble.Text.Xml.Serialization.XmlPolymorphicAttribute
- CloudNimble.Text.Xml.Serialization.XmlDerivedTypeAttribute
- CloudNimble.Text.Xml.Serialization.XmlUnknownDerivedTypeHandling
- CloudNimble.Text.Xml.XmlNamespaces
- CloudNimble.Text.Xml.XmlAttributes