System.Xml.Serialization.XmlSchemaProviderAttribute Class

When applied to a type, stores the name of a static method of the type that returns an XML schema and a System.Xml.XmlQualifiedName (or System.Xml.Schema.XmlSchemaType for anonymous types) that controls the serialization of the type.

See Also: XmlSchemaProviderAttribute Members

Syntax

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Interface | System.AttributeTargets.All)]
public sealed class XmlSchemaProviderAttribute : Attribute

Remarks

The main purpose of the System.Xml.Serialization.XmlSchemaProviderAttribute is to enable the System.Xml.Serialization.XmlSchemaExporter class to return a schema when queried by the Web Services Description Language tool (WSDL.exe), or when using the Add Web Reference feature of vsprvs. You can control the actual schema for the type in the static method.

Note:

The target class of the attribute must implement the System.Xml.Serialization.IXmlSerializable interface.

The XmlSchemaProviderAttribute.MethodName property returns the name of a static method through reflection. The method, which must be implemented, must take a single parameter, an System.Xml.Schema.XmlSchemaSet object, which the method populates with an System.Xml.Schema.XmlSchema object. The method must also return an System.Xml.XmlQualifiedName object that identifies the data type.

Returning Anonymous Types

An anonymous complex type cannot be created using a method that returns System.Xml.XmlQualifiedName. Because an anonymous type has no name, and you cannot add an anonymous type to a schema, the anonymous type must be returned as an System.Xml.Schema.XmlSchemaType.

Requirements

Namespace: System.Xml.Serialization
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0