MatchAttribute クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文
<AttributeUsageAttribute(AttributeTargets.All)> _ Public NotInheritable Class MatchAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets::All)] public ref class MatchAttribute sealed : public Attribute
テキストのパターン一致を使用すると、XML Web サービスで正規表現を使用して既存の HTML の内容を解析し、活用できます。XML Web サービスは、一致要素を使用してサービスの説明で解析する内容を指定します。一致要素には、既存の HTML ページの内容を解析するための正規表現、解析で大文字小文字を無視する必要があるかどうか、正規表現に一致する内容のインスタンスをいくつ返すかなど、複数の項目を指定します。クライアントが Wsdl.exe ツールを使用してプロキシ クラスを作成すると、Service Description で検出された一致要素の詳細を記述した MatchAttribute が、プロキシ クラスのメソッドに含まれます。
テキストのパターン一致の詳細については、「方法 : Web ページのコンテンツを解析する Web サービスを作成する」を参照してください。
Imports System Imports System.Web.Services.Protocols Public Class MatchAttribute_Example Inherits HttpGetClientProtocol Public Sub New() Url = "http://localhost" End Sub 'New <HttpMethodAttribute(GetType(TextReturnReader), GetType(UrlParameterWriter))> _ Public Function GetHeaders() As Headers Return CType(Invoke("GetHeaders", Url + "/MyHeaders.html", New Object(0) {}), Headers) End Function 'GetHeaders Public Function BeginGetHeaders(ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As _ System.IAsyncResult Return BeginInvoke("GetHeaders", Url + "/MyHeaders.html", New Object(0) {}, _ callback, asyncState) End Function 'BeginGetHeaders Public Function EndGetHeaders(ByVal asyncResult As System.IAsyncResult) As Headers Return CType(EndInvoke(asyncResult), Headers) End Function 'EndGetHeaders End Class 'MatchAttribute_Example Public Class Headers <MatchAttribute("TITLE>(.*?)<")> _ Public Title As String <MatchAttribute("", Pattern:="h1>(.*?)<", IgnoreCase:=True)> _ Public H1 As String <MatchAttribute("H2>((([^<,]*),?)+)<", Group:=3, Capture:=4)> _ Public Element As String <MatchAttribute("H2>((([^<,]*),?){2,})<", Group:=3, MaxRepeats:=0)> _ Public Elements1() As String <MatchAttribute("H2>((([^<,]*),?){2,})<", Group:=3, MaxRepeats:=1)> _ Public Elements2() As String <MatchAttribute("H3 ([^=]*)=([^>]*)", Group:=1)> _ Public Attribute As String <MatchAttribute("H3 ([^=]*)=([^>]*)", Group:=2)> _ Public Value As String End Class 'Headers
using System; using System.Web.Services.Protocols; public class MatchAttribute_Example : HttpGetClientProtocol { public MatchAttribute_Example() { Url = "http://localhost"; } [HttpMethodAttribute(typeof(TextReturnReader), typeof(UrlParameterWriter))] public Example_Headers GetHeaders() { return ((Example_Headers)Invoke("GetHeaders", (Url + "/MyHeaders.html"), new object[0])); } public System.IAsyncResult BeginGetHeaders(System.AsyncCallback callback, object asyncState) { return BeginInvoke("GetHeaders", (Url + "/MyHeaders.html"), new object[0], callback, asyncState); } public Example_Headers EndGetHeaders(System.IAsyncResult asyncResult) { return (Example_Headers)(EndInvoke(asyncResult)); } } public class Example_Headers { [MatchAttribute("TITLE>(.*?)<")] public string Title; [MatchAttribute("", Pattern="h1>(.*?)<", IgnoreCase=true)] public string H1; [MatchAttribute("H2>((([^<,]*),?)+)<", Group=3, Capture=4)] public string Element; [MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=0)] public string[] Elements1; [MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=1)] public string[] Elements2; [MatchAttribute("H3 ([^=]*)=([^>]*)", Group=1)] public string Attribute; [MatchAttribute("H3 ([^=]*)=([^>]*)", Group=2)] public string Value; }
#using <System.dll> #using <System.Web.Services.dll> using namespace System; using namespace System::Web::Services::Protocols; public ref class Example_Headers { public: [MatchAttribute("TITLE>(.*?)<")] String^ Title; [MatchAttribute("",Pattern="h1>(.*?)<",IgnoreCase=true)] String^ H1; [MatchAttribute("H2>((([^<,]*),?)+)<",Group=3,Capture=4)] String^ Element; [MatchAttribute("H2>((([^<,]*),?){2,})<",Group=3,MaxRepeats=0)] array<String^>^ Elements1; [MatchAttribute("H2>((([^<,]*),?){2,})<",Group=3,MaxRepeats=1)] array<String^>^ Elements2; [MatchAttribute("H3 ([^=]*)=([^>]*)",Group=1)] String^ Attribute; [MatchAttribute("H3 ([^=]*)=([^>]*)",Group=2)] String^ Value; }; public ref class MatchAttribute_Example: public HttpGetClientProtocol { public: MatchAttribute_Example() { Url = "http://localhost"; } [HttpMethodAttribute(TextReturnReader::typeid,UrlParameterWriter::typeid)] Example_Headers^ GetHeaders() { return ((Example_Headers^)(Invoke( "GetHeaders", ( Url + "/MyHeaders.html" ), gcnew array<Object^>(0) ))); } System::IAsyncResult^ BeginGetHeaders( System::AsyncCallback^ callback, Object^ asyncState ) { return BeginInvoke( "GetHeaders", ( Url + "/MyHeaders.html" ), gcnew array<Object^>(0), callback, asyncState ); } Example_Headers^ EndGetHeaders( System::IAsyncResult^ asyncResult ) { return (Example_Headers^)(EndInvoke( asyncResult )); } };
import System.*; import System.Web.Services.Protocols.*; public class MatchAttribute_Example extends HttpGetClientProtocol { public MatchAttribute_Example() { set_Url("http://localhost"); } //MatchAttribute_Example /** @attribute HttpMethodAttribute(TextReturnReader.class, UrlParameterWriter.class) */ public Example_Headers GetHeaders() { return (Example_Headers)Invoke("GetHeaders", get_Url() + "/MyHeaders.html", new Object[0]); } //GetHeaders public System.IAsyncResult BeginGetHeaders(System.AsyncCallback callback, Object asyncState) { return BeginInvoke("GetHeaders", get_Url() + "/MyHeaders.html", new Object[0], callback, asyncState); } //BeginGetHeaders public Example_Headers EndGetHeaders(System.IAsyncResult asyncResult) { return (Example_Headers)EndInvoke(asyncResult); } //EndGetHeaders } //MatchAttribute_Example public class Example_Headers { /** @attribute MatchAttribute("TITLE>(.*?)<") */ public String title; /** @attribute MatchAttribute("", Pattern = "h1>(.*?)<", IgnoreCase = true) */ public String h1; /** @attribute MatchAttribute("H2>((([^<,]*),?)+)<", Group = 3, Capture = 4) */ public String element; /** @attribute MatchAttribute("H2>((([^<,]*),?){2,})<", Group = 3, MaxRepeats = 0) */ public String elements1[]; /** @attribute MatchAttribute("H2>((([^<,]*),?){2,})<", Group = 3, MaxRepeats = 1) */ public String elements2[]; /** @attribute MatchAttribute("H3 ([^=]*)=([^>]*)", Group = 1) */ public String attribute; /** @attribute MatchAttribute("H3 ([^=]*)=([^>]*)", Group = 2) */ public String value; } //Example_Headers
System.Attribute
System.Web.Services.Protocols.MatchAttribute
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
MatchAttribute コンストラクタ
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文
解説
このコンストラクタを使用して、指定したパターンで MatchAttribute クラスの新しいインスタンスを作成し、初期化します。
MatchAttribute のインスタンスの初期プロパティ値を次の表に示します。
Public Class Headers <MatchAttribute("TITLE>(.*?)<")> _ Public Title As String <MatchAttribute("", Pattern:="h1>(.*?)<", IgnoreCase:=True)> _ Public H1 As String <MatchAttribute("H2>((([^<,]*),?)+)<", Group:=3, Capture:=4)> _ Public Element As String <MatchAttribute("H2>((([^<,]*),?){2,})<", Group:=3, MaxRepeats:=0)> _ Public Elements1() As String <MatchAttribute("H2>((([^<,]*),?){2,})<", Group:=3, MaxRepeats:=1)> _ Public Elements2() As String <MatchAttribute("H3 ([^=]*)=([^>]*)", Group:=1)> _ Public Attribute As String <MatchAttribute("H3 ([^=]*)=([^>]*)", Group:=2)> _ Public Value As String End Class 'Headers
public class Example_Headers { [MatchAttribute("TITLE>(.*?)<")] public string Title; [MatchAttribute("", Pattern="h1>(.*?)<", IgnoreCase=true)] public string H1; [MatchAttribute("H2>((([^<,]*),?)+)<", Group=3, Capture=4)] public string Element; [MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=0)] public string[] Elements1; [MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=1)] public string[] Elements2; [MatchAttribute("H3 ([^=]*)=([^>]*)", Group=1)] public string Attribute; [MatchAttribute("H3 ([^=]*)=([^>]*)", Group=2)] public string Value; }
public ref class Example_Headers { public: [MatchAttribute("TITLE>(.*?)<")] String^ Title; [MatchAttribute("",Pattern="h1>(.*?)<",IgnoreCase=true)] String^ H1; [MatchAttribute("H2>((([^<,]*),?)+)<",Group=3,Capture=4)] String^ Element; [MatchAttribute("H2>((([^<,]*),?){2,})<",Group=3,MaxRepeats=0)] array<String^>^ Elements1; [MatchAttribute("H2>((([^<,]*),?){2,})<",Group=3,MaxRepeats=1)] array<String^>^ Elements2; [MatchAttribute("H3 ([^=]*)=([^>]*)",Group=1)] String^ Attribute; [MatchAttribute("H3 ([^=]*)=([^>]*)",Group=2)] String^ Value; };
public class Example_Headers { /** @attribute MatchAttribute("TITLE>(.*?)<") */ public String title; /** @attribute MatchAttribute("", Pattern = "h1>(.*?)<", IgnoreCase = true) */ public String h1; /** @attribute MatchAttribute("H2>((([^<,]*),?)+)<", Group = 3, Capture = 4) */ public String element; /** @attribute MatchAttribute("H2>((([^<,]*),?){2,})<", Group = 3, MaxRepeats = 0) */ public String elements1[]; /** @attribute MatchAttribute("H2>((([^<,]*),?){2,})<", Group = 3, MaxRepeats = 1) */ public String elements2[]; /** @attribute MatchAttribute("H3 ([^=]*)=([^>]*)", Group = 1) */ public String attribute; /** @attribute MatchAttribute("H3 ([^=]*)=([^>]*)", Group = 2) */ public String value; } //Example_Headers
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
MatchAttribute プロパティ
パブリック プロパティ
名前 | 説明 | |
---|---|---|
Capture | グループ内の一致のインデックスを表す値を取得または設定します。 | |
Group | 関連する一致のグループ化を表す値を取得または設定します。 | |
IgnoreCase | 一致させるパターンが、大文字小文字を区別しないかどうかを示す値を取得または設定します。 | |
MaxRepeats | 一致した値を返す個数について、その最大個数を取得または設定します。 | |
Pattern | 一致させるパターンを表す正規表現を取得または設定します。 | |
TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |
MatchAttribute メソッド
パブリック メソッド
名前 | 説明 | |
---|---|---|
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 から継承されます。) |
MatchAttribute メンバ
テキストのパターン一致により一致した属性を表します。このクラスは継承できません。
MatchAttribute データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック プロパティ
名前 | 説明 | |
---|---|---|
Capture | グループ内の一致のインデックスを表す値を取得または設定します。 | |
Group | 関連する一致のグループ化を表す値を取得または設定します。 | |
IgnoreCase | 一致させるパターンが、大文字小文字を区別しないかどうかを示す値を取得または設定します。 | |
MaxRepeats | 一致した値を返す個数について、その最大個数を取得または設定します。 | |
Pattern | 一致させるパターンを表す正規表現を取得または設定します。 | |
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 から継承されます。) |
- MatchAttributeのページへのリンク