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

 

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

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

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

Parameters

baseAddress
Type: System.Uri

A Uri instance that contains the base address.

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 call this constructor.

Uri baseAddress = new Uri("http://localhost/");
//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(baseAddress, list);
table.MakeReadOnly(true);

.NET Framework
Available since 3.5
Return to top
Show: