XmlSchemaProviderAttribute クラス
アセンブリ: System.Xml (system.xml.dll 内)

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Interface)> _ Public NotInheritable Class XmlSchemaProviderAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Interface)] public sealed class XmlSchemaProviderAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Interface)] public ref class XmlSchemaProviderAttribute sealed : public Attribute

XmlSchemaProviderAttribute の主な役目は、Web サービス記述言語ツール (WSDL.exe) から問い合わせがあった場合、または Visual Studio の [Web 参照の追加] 機能を使用する場合に、XmlSchemaExporter クラスがスキーマを返せるようにすることです。型の実際のスキーマの制御は静的メソッドで行うことができます。
![]() |
---|
MethodName プロパティは、リフレクションを介して静的メソッドの名前を返します。実装の必要があるこのメソッドは、単一のパラメータである XmlSchemaSet オブジェクトを使用する必要があります。このメソッドは、このオブジェクトに XmlSchema オブジェクトを読み込みます。またこのメソッドは、データ型を識別する XmlQualifiedName オブジェクトを返す必要もあります。

次の例では、XmlSchemaProviderAttribute をサーバー側のクラスに適用しています。呼び出しを行うと、MethodName プロパティによって名前が指定されているメソッドがスキーマを作成します。この単純な実装では、ディスクから既存のスキーマを読み込みます。ただし、System.Xml.Schema 名前空間にある型を使用すると、必要に応じて、カスタム スキーマも作成できます。
<XmlSchemaProvider("MySchema")> _ Public Class SongStream Implements IXmlSerializable Private Const ns As String = "http://demos.Contoso.com/webservices" Private filePath As String Public Sub New() End Sub Public Sub New(ByVal filePath As String) Me.filePath = filePath End Sub ' This is the method named by the XmlSchemaProviderAttribute applied to the type. Public Shared Function MySchema(ByVal xs As XmlSchemaSet) As XmlQualifiedName ' This method is called by the framework to get the schema for this type. ' We return an existing schema from disk. Dim schemaSerializer As New XmlSerializer(GetType(XmlSchema)) Dim xsdPath As String = Nothing ' NOTE: replace SongStream.xsd with your own schema file. xsdPath = System.Web.HttpContext.Current.Server.MapPath("SongStream.xsd") Dim s As XmlSchema = CType(schemaSerializer.Deserialize(New XmlTextReader(xsdPath)), XmlSchema) xs.XmlResolver = New XmlUrlResolver() xs.Add(s) Return New XmlQualifiedName("songStream", ns) End Function Sub WriteXml(ByVal writer As System.Xml.XmlWriter) Implements IXmlSerializable.WriteXml ' This is the chunking code. ' ASP.NET buffering must be turned off for this to work. Dim bufferSize As Integer = 4096 Dim songBytes(bufferSize) As Char Dim inFile As FileStream = File.Open(Me.filePath, FileMode.Open, FileAccess.Read) Dim length As Long = inFile.Length ' Write the file name. writer.WriteElementString("fileName", ns, Path.GetFileNameWithoutExtension(Me.filePath)) ' Write the size. writer.WriteElementString("size", ns, length.ToString()) ' Write the song bytes. writer.WriteStartElement("song", ns) Dim sr As New StreamReader(inFile, True) Dim readLen As Integer = sr.Read(songBytes, 0, bufferSize) While readLen > 0 writer.WriteStartElement("chunk", ns) writer.WriteChars(songBytes, 0, readLen) writer.WriteEndElement() writer.Flush() readLen = sr.Read(songBytes, 0, bufferSize) End While writer.WriteEndElement() inFile.Close() End Sub Function GetSchema() As System.Xml.Schema.XmlSchema Implements IXmlSerializable.GetSchema Throw New System.NotImplementedException() End Function Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements IXmlSerializable.ReadXml Throw New System.NotImplementedException() End Sub End Class
[XmlSchemaProvider("MySchema")] public class SongStream : IXmlSerializable { private const string ns = "http://demos.Contoso.com/webservices"; private string filePath; public SongStream(){ } public SongStream(string filePath) { this.filePath = filePath; } // This is the method named by the XmlSchemaProviderAttribute applied to the type. public static XmlQualifiedName MySchema(XmlSchemaSet xs) { // This method is called by the framework to get the schema for this type. // We return an existing schema from disk. XmlSerializer schemaSerializer = new XmlSerializer(typeof(XmlSchema)); string xsdPath = null; // NOTE: replace the string with your own path. xsdPath = System.Web.HttpContext.Current.Server.MapPath("SongStream.xsd"); XmlSchema s = (XmlSchema)schemaSerializer.Deserialize( new XmlTextReader(xsdPath), null); xs.XmlResolver = new XmlUrlResolver(); xs.Add(s); return new XmlQualifiedName("songStream", ns); } void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { // This is the chunking code. // ASP.NET buffering must be turned off for this to work. int bufferSize = 4096; char[] songBytes = new char[bufferSize]; FileStream inFile = File.Open(this.filePath, FileMode.Open, FileAccess.Read); long length = inFile.Length; // Write the file name. writer.WriteElementString("fileName", ns, Path.GetFileNameWithoutExtension(this.filePath)); // Write the size. writer.WriteElementString("size", ns, length.ToString()); // Write the song bytes. writer.WriteStartElement("song", ns); StreamReader sr = new StreamReader(inFile, true); int readLen = sr.Read(songBytes, 0, bufferSize); while (readLen > 0) { writer.WriteStartElement("chunk", ns); writer.WriteChars(songBytes, 0, readLen); writer.WriteEndElement(); writer.Flush(); readLen = sr.Read(songBytes, 0, bufferSize); } writer.WriteEndElement(); inFile.Close(); } System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() { throw new System.NotImplementedException(); } void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { throw new System.NotImplementedException(); } }

System.Attribute
System.Xml.Serialization.XmlSchemaProviderAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


XmlSchemaProviderAttribute コンストラクタ
アセンブリ: System.Xml (system.xml.dll 内)


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


XmlSchemaProviderAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() | IsAny | ターゲット クラスがワイルドカードかどうか、またはクラスのスキーマに xs:any 要素のみが含まれているかどうかを判断する値を取得または設定します。 |
![]() ![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |

XmlSchemaProviderAttribute メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

XmlSchemaProviderAttribute メンバ
型に適用された場合、XML スキーマを返す型の静的メソッドの名前と、型のシリアル化を制御する XmlQualifiedName を格納します。
XmlSchemaProviderAttribute データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | XmlSchemaProviderAttribute | 型の XML スキーマを提供する静的メソッドの名前を受け取って、XmlSchemaProviderAttribute クラスの新しいインスタンスを初期化します。 |

名前 | 説明 | |
---|---|---|
![]() | IsAny | ターゲット クラスがワイルドカードかどうか、またはクラスのスキーマに xs:any 要素のみが含まれているかどうかを判断する値を取得または設定します。 |
![]() ![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 ( Attribute から継承されます。) |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) |
![]() | GetHashCode | このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からXmlSchemaProviderAttributeを検索する場合は、下記のリンクをクリックしてください。

- XmlSchemaProviderAttributeのページへのリンク