Freigeben über


MatchAttribute-Klasse

Stellt die Attribute eines Vergleichs dar, der anhand von Textmustern durchgeführt wurde. Diese Klasse kann nicht geerbt werden.

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.All)> _
Public NotInheritable Class MatchAttribute
    Inherits Attribute
'Usage
Dim instance As MatchAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public sealed class MatchAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class MatchAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public final class MatchAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public final class MatchAttribute extends Attribute

Hinweise

Der Textmustervergleich ermöglicht es einem XML-Webdienst, bereits vorhandenen HTML-Inhalt dadurch zu nutzen, dass er unter Verwendung regulärer Ausdrücke analysiert wird. Ein XML-Webdienst gibt den zu analysierenden Inhalt in einer Dienstbeschreibung unter Verwendung der Übereinstimmungselemente an. Diese Vergleichselemente enthalten mehrere Angaben: der reguläre Ausdruck zum Analysieren des Inhalts einer vorhandenen HTML-Seite, Beachtung bzw. Ignorieren der Groß- und Kleinschreibung beim Analysieren sowie die Anzahl der mit dem regulären Ausdruck übereinstimmenden Instanzen, die zurückgegeben werden sollen. Wenn ein Client mit dem Tool Wsdl.exe eine Proxyklasse erstellt, enthalten die Methoden der Proxyklasse ein MatchAttribute mit ausführlichen Informationen über die in der Dienstbeschreibung angegebenen Vergleichselemente.

Weitere Informationen über Textmustervergleiche finden Sie unter Gewusst wie: Erstellen von Webdiensten, die den Inhalt einer Webseite analysieren.

Beispiel

Imports System
Imports System.Web.Services.Protocols


Public Class MatchAttribute_Example
    Inherits HttpGetClientProtocol

    Public Sub New()
        Url = "https://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 = "https://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 = "https://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("https://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

Vererbungshierarchie

System.Object
   System.Attribute
    System.Web.Services.Protocols.MatchAttribute

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

MatchAttribute-Member
System.Web.Services.Protocols-Namespace