IXmlSerializable.GetSchema IXmlSerializable.GetSchema IXmlSerializable.GetSchema IXmlSerializable.GetSchema Method

定义

此方法是保留方法,请不要使用。This method is reserved and should not be used. 在实现 IXmlSerializable 接口时,应从此方法返回 null(在 Visual Basic 中为 Nothing),如果需要指定自定义架构,应向该类应用 XmlSchemaProviderAttributeWhen implementing the IXmlSerializable interface, you should return null (Nothing in Visual Basic) from this method, and instead, if specifying a custom schema is required, apply the XmlSchemaProviderAttribute to the class.

public:
 System::Xml::Schema::XmlSchema ^ GetSchema();
public System.Xml.Schema.XmlSchema GetSchema ();
abstract member GetSchema : unit -> System.Xml.Schema.XmlSchema
Public Function GetSchema () As XmlSchema

返回

一个 XmlSchema,描述由 WriteXml(XmlWriter) 方法生成并由 ReadXml(XmlReader) 方法使用的对象的 XML 表示形式。An XmlSchema that describes the XML representation of the object that is produced by the WriteXml(XmlWriter) method and consumed by the ReadXml(XmlReader) method.

注解

序列化或反序列化对象时XmlSerializer , 类不执行 XML 验证。When serializing or deserializing an object, the XmlSerializer class does not perform XML validation. 出于此原因, 通过提供此方法的普通实现 (例如null Nothing , 在 Visual Basic 中), 通常可以安全地省略架构信息。For this reason, it is often safe to omit schema information by providing a trivial implementation of this method, for example by returning null (Nothing in Visual Basic).

如果需要提供架构信息, 则应该使用XmlSchemaProviderAttribute特性。If providing schema information is necessary, you should use the XmlSchemaProviderAttribute attribute. 方法应仍返回null (或Nothing)。 GetSchemaThe GetSchema method should still return null (or Nothing).

某些.NET Framework.NET Framework类型以及实现接口的IXmlSerializable旧自定义类型XmlSchemaProvider可能使用GetSchema而不是。Some .NET Framework.NET Framework types as well as legacy custom types implementing the IXmlSerializable interface may be using GetSchema instead of XmlSchemaProvider. 在这种情况下, 方法返回准确的 xml 架构, 该架构描述WriteXml方法所生成的对象的 XML 表示形式。In this case, the method returns an accurate XML schema that describes the XML representation of the object generated by the WriteXml method.

适用于