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

定義

這個方法已保留且不應使用。This method is reserved and should not be used. 實作 IXmlSerializable 介面時,您應該從這個方法傳回 null (在 Visual Basic 中為 Nothing),而且如果需要指定自訂結構描述,請改為將 XmlSchemaProviderAttribute 套用至類別。When 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,描述物件的 XML 表示,該物件由 WriteXml(XmlWriter) 方法產生,由 ReadXml(XmlReader) 方法取用。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. 方法仍應傳回Nothing(或)。 null 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.

適用於