Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

UriTemplateTable.KeyValuePairs Property

Gets a collection of key/value pairs that consist of UriTemplate objects and their associated data.

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

'Declaration
Public ReadOnly Property KeyValuePairs As IList(Of KeyValuePair(Of UriTemplate, Object))

Property Value

Type: System.Collections.Generic.IList(Of KeyValuePair(Of UriTemplate, Object))
A collection of key/value pairs that consist of UriTemplate objects and their associated data.

Each UriTemplate instance in the table has data associated with it. The KeyValuePairs property contains a collection of key value pairs where the key is a UriTemplate instance and the value is the data associated with the UriTemplate. Values can only be added to KeyValuePairs property prior to calling MakeReadOnly(Boolean) or Match(Uri) or MatchSingle(Uri) otherwise a NotSupportedException is thrown.

The following example shows how to access the KeyValuePairs property.

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"))

table.MakeReadOnly(True)

Console.WriteLine("KeyValuePairs:")
For Each keyPair As KeyValuePair(Of UriTemplate, Object) In table.KeyValuePairs
    Console.WriteLine("     0},  1}", keyPair.Key, keyPair.Value)
Next

Console.WriteLine()

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft