Export (0) Print
Expand All

MatchAttribute Class

Represents the attributes of a match made using text pattern matching. This class cannot be inherited.

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

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

[AttributeUsageAttribute(AttributeTargets.All)]
public sealed class MatchAttribute : Attribute

The MatchAttribute type exposes the following members.

  NameDescription
Public methodMatchAttributeInitializes a new instance of the MatchAttribute class with the specified pattern.
Top

  NameDescription
Public propertyCaptureGets or sets a value that represents the index of a match within a grouping.
Public propertyGroupGets or sets a value that represents a grouping of related matches.
Public propertyIgnoreCaseGets or sets a value that indicates whether the pattern to match is case insensitive.
Public propertyMaxRepeatsGets or sets the maximum number of values to return from the match.
Public propertyPatternGets or sets a regular expression that represents the pattern to match.
Public propertyTypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Top

  NameDescription
Public methodEqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Public methodGetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIsDefaultAttributeWhen overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public methodMatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate method_Attribute.GetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoRetrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.InvokeProvides access to properties and methods exposed by an object. (Inherited from Attribute.)
Top

Text pattern matching allows an XML Web service to leverage existing HTML content by parsing it using regular expressions. an XML Web service specifies the content it wants to parse in a Service Description using match elements. 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. 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.

For more information on text pattern matching, see [<topic://cpconcreatingclientsthatparsecontentofotherwebpages>].

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));
	}
}
// <Snippet5> 
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;
}
// </Snippet4>

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft