This documentation is archived and is not being maintained.

UriTemplateTable Constructor (Uri)

Initializes a new instance of the UriTemplateTable class with the specified base address.

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

public UriTemplateTable(
	Uri baseAddress


Type: System.Uri

A Uri instance that contains the base address.

The following example shows how to call this constructor.

Uri prefix = new Uri("http://localhost/");

//Create some templates:
UriTemplate weatherByCity = new UriTemplate("weather/{state}/{city}");
UriTemplate weatherByState = new UriTemplate("weather/{state}");
UriTemplate traffic = new UriTemplate("traffic/*");
UriTemplate wildcard = new UriTemplate("*");

// Create a template table
UriTemplateTable table = new UriTemplateTable(prefix);

// Add the templates to the template table along with some associated data
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, object>(weatherByCity, "weatherByCity"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, object>(weatherByState, "weatherByState"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, object>(traffic, "traffic"));

// Match a URI to a template
Uri candidateUri = new Uri("http://localhost/weather/WA/Redmond");
UriTemplateMatch results = table.MatchSingle(candidateUri);

if (results != null)
    // Get the data associated with the matching template
    string data = (string)results.Data;
    Console.WriteLine("Matching data is {0}", data);

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