UriTemplateTable Constructor (IEnumerable(KeyValuePair(UriTemplate, Object)))

UriTemplateTable Constructor (IEnumerable<KeyValuePair<UriTemplate, Object>>)

 

Initializes a new instance of the UriTemplateTable class with the specified collection of key/value pairs.

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

public UriTemplateTable(
	IEnumerable<KeyValuePair<UriTemplate, object>> keyValuePairs
)

Parameters

keyValuePairs
Type: System.Collections.Generic.IEnumerable<KeyValuePair<UriTemplate, Object>>

A collection of key/value pairs that consist of URI templates and associated data.

The following example shows how to instantiate the UriTemplateTable class.

//Create a series of templates
UriTemplate weatherByCity = new UriTemplate("weather/{state}/{city}");
UriTemplate weatherByCountry = new UriTemplate("weather/{country}/{village}");
UriTemplate weatherByState = new UriTemplate("weather/{state}");
UriTemplate traffic = new UriTemplate("traffic/*");
UriTemplate wildcard = new UriTemplate("*");

//Add each template to the table with some associated data
List<KeyValuePair<UriTemplate,Object>> list = new List<KeyValuePair<UriTemplate,object>>();
list.Add(new KeyValuePair<UriTemplate, Object>(weatherByCity, "weatherByCity"));
list.Add(new KeyValuePair<UriTemplate, Object>(weatherByCountry, "weatherByCountry"));
list.Add(new KeyValuePair<UriTemplate, Object>(weatherByState, "weatherByState"));
list.Add(new KeyValuePair<UriTemplate, Object>(traffic, "traffic"));

//Create a template table
UriTemplateTable table = new UriTemplateTable(list);
table.BaseAddress = new Uri("http://localhost/");
table.MakeReadOnly(true);

.NET Framework
Available since 3.5
Return to top
Show:
© 2016 Microsoft