Aracılığıyla paylaş


XmlAttributeOverrides.Add Method (Type, String, XmlAttributes)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Adds an XmlAttributes object to the collection of XmlAttributes objects. The type parameter specifies an object to be overridden. The member parameter specifies the name of a member that is overridden.

Namespace:  System.Xml.Serialization
Assembly:  System.Xml.Serialization (in System.Xml.Serialization.dll)

Syntax

'Declaration
Public Sub Add ( _
    type As Type, _
    member As String, _
    attributes As XmlAttributes _
)
public void Add(
    Type type,
    string member,
    XmlAttributes attributes
)

Parameters

Exceptions

Exception Condition
InvalidOperationException

More than one XmlAttributes object was added for a member of some type.

Remarks

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 method when attempting to override an XmlElementAttribute, XmlAttributeAttribute, XmlArrayAttribute, XmlArrayItemAttribute, or XmlIgnoreAttribute.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.