UriTemplate Class
A class that represents a Uniform Resource Identifier (URI) template.
Namespace: System
Assembly: System.ServiceModel.Web.Extensions (in System.ServiceModel.Web.Extensions.dll)
The UriTemplate type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | UriTemplate(String) | Initializes a new instance of the UriTemplate class with the specified template string. |
![]() | UriTemplate(String, Boolean) | Initializes a new instance of the UriTemplate class. |
![]() | UriTemplate(String, IDictionary<String, String>) | Initializes a new instance of the UriTemplate class. |
![]() | UriTemplate(String, Boolean, IDictionary<String, String>) | Initializes a new instance of the UriTemplate class. |
| Name | Description | |
|---|---|---|
![]() | IgnoreTrailingSlash | Specifies whether trailing slashes “/” in the template should be ignored when binding parameters to create a URI. |
![]() | PathSegmentVariableNames | Gets a collection of variable names used within path segments in the template. |
![]() | QueryValueVariableNames | Gets a collection of variable names used within the query string in the template. |
| Name | Description | |
|---|---|---|
![]() | BindByName(Uri, IDictionary<String, String>) | Creates a new URI from the template and the collection of parameters. |
![]() | BindByName(Uri, IDictionary<String, String>, Boolean) | Creates a new URI from the template and the collection of parameters. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string representation of the UriTemplate instance. (Overrides Object::ToString().) |
A URI template allows you to define a set of structurally similar URIs. Templates are composed of two parts, a path and a query.
A path consists of a series of segments delimited by a slash (/). Each segment can have a literal value, a variable value (written within curly braces [{ }], constrained to match the contents of exactly one segment), or a wildcard (written as an asterisk [*], which matches "the rest of the path"), which must appear at the end of the path.
The query expression can be omitted entirely. If present, it specifies an unordered series of name/value pairs. Elements of the query expression can be either literal pairs (?x=2) or variable pairs (?x={val}). Unpaired values are not permitted. The following examples show valid template strings:
"weather/WA/Seattle"
"weather/{state}/{city}"
"weather/*"
"weather/{state}/{city}?forecast=today
"weather/{state}/{city}?forecast={day}
The preceding URI templates might be used for organizing weather reports. Segments enclosed in curly braces are variables, everything else is a literal. You can convert a UriTemplate instance into a Uri by replacing variables with actual values. For example, taking the template "weather/{state}/{city}" and putting in values for the variables "{state}" and "{city}" gives you "weather/WA/Seattle".
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
