Export (0) Print
Expand All

UriTemplateMatch.Data Property

Gets and sets the object associated with the UriTemplateMatch instance.

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

Public Property Data As Object
Dim instance As UriTemplateMatch 
Dim value As Object 

value = instance.Data

instance.Data = value

Property Value

Type: System.Object
An Object instance.

When you add a UriTemplate to a UriTemplateTable you associate data with the template. This value is application specific; no particular semantics are associated with this value. When Match(Uri) is called and a match is found the data associated with the matching template is returned in the Data property.

The following code shows how to access the Data property.

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

' Create some templates: 
Dim weatherByCity As New UriTemplate("weather/ state}/ city}")
Dim weatherByState As New UriTemplate("weather/ state}")
Dim traffic As New UriTemplate("traffic/*")
Dim wildcard As New UriTemplate("*")

'Create a template table 
Dim table As UriTemplateTable = New UriTemplateTable(prefix)

'Add the templates to the template table along with some associated data
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByCity, "weatherByCity"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByState, "weatherByState"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(traffic, "traffic"))

'Match a URI to a template 
Dim candidateUri As New Uri("http://localhost/weather/WA/Redmond")
Dim results As UriTemplateMatch = table.MatchSingle(candidateUri)

If (results IsNot Nothing) Then 

    'Get the data associated with the matching template 
    Dim data As String = CType(results.Data, String)
    Console.WriteLine("Matching data is  0}", Data)
End If

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5

Community Additions

© 2014 Microsoft