MatchAttribute クラス

定義

テキストのパターン マッチにより一致した属性を表します。 このクラスは継承できません。

public ref class MatchAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class MatchAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type MatchAttribute = class
    inherit Attribute
Public NotInheritable Class MatchAttribute
Inherits Attribute
継承
MatchAttribute
属性

#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 ));
   }
};
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;
}
Imports System.Web.Services.Protocols


Public Class MatchAttribute_Example
    Inherits HttpGetClientProtocol

    Public Sub New()
        Url = "http://localhost"
    End Sub

    <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

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

注釈

テキスト パターン マッチングを使用すると、XML Web サービスは正規表現を使用して解析することで、既存の HTML コンテンツを利用できます。 XML Web サービスは、match 要素を使用してサービスの説明で解析するコンテンツを指定します。 これらの一致要素は、いくつかの項目を指定します。既存の HTML ページの内容を解析するための正規表現、解析で大文字と小文字を区別しないかどうか、正規表現に一致するコンテンツのインスタンスの数を返す必要があります。 クライアントがWsdl.exe ツールを使用してプロキシ クラスを構築する場合、プロキシ クラスのメソッドには、サービスの説明に含まれる一致要素の詳細が含まれます MatchAttribute

テキスト パターン マッチングの詳細については、「 方法: Web ページのコンテンツを解析する Web サービスを作成する」を参照してください。

コンストラクター

MatchAttribute(String)

パターンを指定して、MatchAttribute クラスの新しいインスタンスを初期化します。

プロパティ

Capture

グループ内の一致のインデックスを表す値を取得または設定します。

Group

関連する一致のグループ化を表す値を取得または設定します。

IgnoreCase

一致させるパターンが、大文字小文字を区別しないかどうかを示す値を取得または設定します。

MaxRepeats

一致した値を返す個数について、その最大個数を取得または設定します。

Pattern

一致させるパターンを表す正規表現を取得または設定します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象