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)

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


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


.NET Framework
Available since 3.5
Return to top