IXmlSerializable.GetSchema メソッド
定義
このメソッドは予約されているため、使用できません。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 ();
public System.Xml.Schema.XmlSchema? GetSchema ();
abstract member GetSchema : unit -> System.Xml.Schema.XmlSchema
Public Function GetSchema () As XmlSchema
戻り値
XmlSchema メソッドで生成され、WriteXml(XmlWriter) メソッドで利用されるオブジェクトの XML 表現を表す 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
(Visual Basic で) を返すなどして、このメソッドの単純な実装を提供することで、スキーマ情報を省略することが安全です Nothing
。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. メソッドは、 GetSchema
引き続き null
(または) を返す必要があり Nothing
ます。The GetSchema
method should still return null
(or Nothing
).
.NET Framework.NET Frameworkインターフェイスを実装するレガシカスタム型に加えて、 IXmlSerializable
の代わりにを使用している型もあり GetSchema
XmlSchemaProvider
ます。Some .NET Framework.NET Framework types as well as legacy custom types implementing the IXmlSerializable
interface may be using GetSchema
instead of XmlSchemaProvider
. この場合、メソッドは、メソッドによって生成されるオブジェクトの XML 表現を記述する正確な XML スキーマを返し WriteXml ます。In this case, the method returns an accurate XML schema that describes the XML representation of the object generated by the WriteXml method.