Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml.SerializationSyntax
Summary
Represents the XML attributes and child elements that have no matching member and are captured by a member marked with XmlExtensionDataAttribute. This class cannot be inherited.Usage
XmlExtensionData holds the attributes and child elements of an element that no member of your type maps. Add a member of this type, mark it with [XmlExtensionData], and the serializer fills it when it reads and writes its content back when it serializes. It is the XML counterpart of the dictionary that [JsonExtensionData] uses in System.Text.Json.
Both collections are created with the object and are never
null. You can read them after deserializing, and add to them before serializing.
Examples
Round-trip content the type doesn’t declare
TheSettings type maps only Theme. The document also has two attributes and two elements, one of each in a namespace. They are captured, and written back after the mapped member changes.
Considerations
- Position. When writing, unmapped attributes follow the mapped attributes and unmapped elements follow the mapped elements. Where an unmapped element stood among the mapped ones is not recorded.
- Namespace declarations.
xmlnsattributes are not captured and are not written fromAttributes. The writer declares the namespaces that the captured names need. - Prefixes. A captured attribute keeps the prefix it was read with, in the
Prefixof itsXmlName. An attribute that you add with a namespace and no prefix gets a generated prefix. - Serializer attributes.
xsi:nil,xsi:type, and theidandrefattributes of reference handling are consumed by the serializer and are not captured. - Keys.
XmlNameequality ignores the prefix, so two attributes with the same local name and namespace are one entry. - Allocation. Each captured element is a mutable
XmlElementNodetree. Capturing large unmapped subtrees costs one node for every element, attribute, and text run in them. If you don’t need the content, leave the member out and let the serializer skip it. - Thread safety. The object is an ordinary mutable class with a dictionary and a list. Don’t change it from several threads at once.
Constructors
.ctor
Syntax
.ctor Inherited
Inherited from
objectSyntax
Properties
Attributes
Gets the XML attributes that have no matching member.Syntax
Property Value
Type:System.Collections.Generic.Dictionary<CloudNimble.Text.Xml.XmlName, string>
A dictionary that maps the name of each unmapped attribute to its value.
Elements
Gets the child elements that have no matching member.Syntax
Property Value
Type:System.Collections.Generic.List<CloudNimble.Text.Xml.Nodes.XmlElementNode>
A list of the unmapped child elements, in document order.
Methods
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Related APIs
- CloudNimble.Text.Xml.Serialization.XmlExtensionDataAttribute
- CloudNimble.Text.Xml.Serialization.XmlUnmappedMemberHandling
- CloudNimble.Text.Xml.XmlName
- CloudNimble.Text.Xml.Nodes.XmlElementNode
- CloudNimble.Text.Xml.XmlSerializerOptions