MatchAttribute MatchAttribute MatchAttribute MatchAttribute Class

Definición

Representa los atributos de una coincidencia encontrada utilizando la coincidencia de modelos de texto.Represents the attributes of a match made using text pattern matching. Esta clase no puede heredarse.This class cannot be inherited.

public ref class MatchAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class MatchAttribute : Attribute
type MatchAttribute = class
    inherit Attribute
Public NotInheritable Class MatchAttribute
Inherits Attribute
Herencia
MatchAttributeMatchAttributeMatchAttributeMatchAttribute
Atributos

Ejemplos

#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
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

Comentarios

Coincidencia de patrones de texto permite que un servicio Web XML aprovechar el código HTML existente contenido mediante el análisis mediante expresiones regulares.Text pattern matching allows an XML Web service to leverage existing HTML content by parsing it using regular expressions. un servicio Web XML especifica el contenido que desea analizar en una descripción del servicio utilizando elementos coincidentes.an XML Web service specifies the content it wants to parse in a Service Description using match elements. Estos elementos coincidentes especificar varios elementos: la expresión regular para analizar el contenido de HTML existente en una página, si el análisis debe distinguir mayúsculas de minúsculas y se debe devolver el número de instancias de contenido que coincida con la expresión regular.These match elements specify several items: the regular expression for parsing the contents of an existing HTML page, whether the parsing must be case-insensitive, and how many instances of content that matches the regular expression should be returned. Cuando un cliente crea una clase de proxy mediante la herramienta Wsdl.exe, los métodos de la clase de proxy incluyen un MatchAttribute que detalla los elementos coincidentes se encuentra en la descripción del servicio.When a client builds a proxy class using the Wsdl.exe tool, methods of the proxy class include a MatchAttribute detailing the match elements found in the Service Description.

Para obtener más información sobre la coincidencia de patrón de texto, vea Cómo: Crear servicios Web que analicen el contenido de una página Web.For more information on text pattern matching, see How to: Create Web Services That Parse the Contents of a Web Page.

Constructores

MatchAttribute(String) MatchAttribute(String) MatchAttribute(String) MatchAttribute(String)

Inicializa una nueva instancia de la clase MatchAttribute con el modelo especificado.Initializes a new instance of the MatchAttribute class with the specified pattern.

Propiedades

Capture Capture Capture Capture

Obtiene o establece un valor que representa el índice de una coincidencia en una agrupación.Gets or sets a value that represents the index of a match within a grouping.

Group Group Group Group

Obtiene o establece un valor que representa una agrupación de coincidencias relacionadas.Gets or sets a value that represents a grouping of related matches.

IgnoreCase IgnoreCase IgnoreCase IgnoreCase

Obtiene o establece un valor que indica si el modelo de coincidencia no distingue mayúsculas de minúsculas.Gets or sets a value that indicates whether the pattern to match is case insensitive.

MaxRepeats MaxRepeats MaxRepeats MaxRepeats

Obtiene o establece el número máximo de valores que se van a devolver a partir de una búsqueda de coincidencias.Gets or sets the maximum number of values to return from the match.

Pattern Pattern Pattern Pattern

Obtiene o establece una expresión regular que representa el modelo de coincidencia.Gets or sets a regular expression that represents the pattern to match.

TypeId TypeId TypeId TypeId

Cuando se implementa en una clase derivada, obtiene un identificador único para este Attribute.When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Devuelve un valor que indica si esta instancia es igual que un objeto especificado.Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Devuelve el código hash de esta instancia.Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

Si se reemplaza en una clase derivada, indica si el valor de esta instancia es el valor predeterminado de la clase derivada.When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

Cuando se invalida en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Implementaciones de interfaz explícitas

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

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Obtiene la información de tipos de un objeto, que puede utilizarse para obtener la información de tipos de una interfaz.Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

Se aplica a