XmlAttributeOverrides.Add Method (Type, XmlAttributes)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Adds an XmlAttributes object to the collection of XmlAttributes objects. The type parameter specifies an object to be overridden by the XmlAttributes object.
Assembly: System.Xml.Serialization (in System.Xml.Serialization.dll)
Parameters
- type
- Type: System.Type
The Type of the object that is overridden.
- attributes
- Type: System.Xml.Serialization.XmlAttributes
An XmlAttributes object that represents the overriding attributes.
| Exception | Condition |
|---|---|
| InvalidOperationException | More than one XmlAttributes object was added for a member of some type. |
The XmlAttributes object contains a union of attribute objects that cause the XmlSerializer to override its default serialization behavior for a set of objects. You choose the attribute objects to place in the XmlAttributes object, depending on the particular behaviors you want to override. For example, the XmlSerializer serializes a class member as an XML element by default. If you want the member to be serialized as an XML attribute instead, you would create an XmlAttributeAttribute, assign it to the XmlAttribute property of an XmlAttributes, and add the XmlAttributes object to the XmlAttributeOverrides object.
Use this overload to override an XmlRootAttribute or XmlTypeAttribute.