This documentation is archived and is not being maintained.

UriTemplateTable.Match Method

Attempts to match a candidate Uri to the UriTemplateTable.

Namespace:  System
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Public Function Match ( _
	uri As Uri _
) As Collection(Of UriTemplateMatch)


Type: System.Uri
The candidate URI.

Return Value

Type: System.Collections.ObjectModel.Collection(Of UriTemplateMatch)
A collection of UriTemplateMatch instances.

This method may return multiple matches.

The following example shows how to call the Match(Uri) method.

Dim prefix As New Uri("http://localhost/")

' Create a series of templates
Dim weatherByCity = New UriTemplate("weather/ state}/ city}")
Dim weatherByCountry = New UriTemplate("weather/ country}/ village}")
Dim weatherByState = New UriTemplate("weather/ state}")
Dim traffic = New UriTemplate("traffic/*")
Dim wildcard = New UriTemplate("*")

' Create a template table
Dim table As New UriTemplateTable(prefix)
' Add each template to the table with some associated data
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByCity, "weatherByCity"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByCountry, "weatherByCountry"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByState, "weatherByState"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(traffic, "traffic"))


' Call Match to retrieve some match results:
Dim results As ICollection(Of UriTemplateMatch)
results = Nothing
Dim weatherInSeattle As New Uri("http://localhost/weather/Washington/Seattle")

results = table.Match(weatherInSeattle)
If (results IsNot Nothing) Then

    Console.WriteLine("Matching templates:")
    For Each match As UriTemplateMatch In results
        Console.WriteLine("    0}", match.Template)
End If

.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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