User Guide |
This library provides support for URI Templates (Level 4) as defined by RFC 6570.
The following text from the introduction to RFC 6570 defines the basic purpose of a URI Template.
A URI Template is a compact sequence of characters for describing a range of Uniform Resource Identifiers through variable expansion. This specification defines the URI Template syntax and the process for expanding a URI Template into a URI reference, along with guidelines for the use of URI Templates on the Internet.
In this library, URI Templates are represented by instances of the UriTemplate class.
The following example shows a URI template describing the path to information about a package hosted at NuGet.
/packages/{id}{/version}
This URI Template contains two expansion variables. The id variable represents the package ID, and the version variable represents the specific version of the package. By providing specific values for these variables, a URI instance can be obtained which references a specific desired NuGet package. The following list shows two specific ways these values could be assigned:
If the id is specified as TunnelVisionLabs.Net.UriTemplate, but the version is left unspecified, the template expansion operation produces the relative URI /packages/TunnelVisionLabs.Net.UriTemplate. Since this URI does not specify a specific version, NuGet will display the information for the latest version of the package.
If the id is specified as TunnelVisionLabs.Net.UriTemplate and the version is specified as 1.0.0, the template expansion operation produces the relative URI /packages/TunnelVisionLabs.Net.UriTemplate/1.0.0. This is the path to information about version 1.0.0 of the package.
The following sections describe the basic operations supported by this library for operating on URI Templates.
Template expansion is the process of assigning values to the expressions in a URI Template to produce a URI. The expansion functionality is provided by the BindByName method and described in further detail in the Template Expansion topic.
Matching is the process of extracting values of individual variables from a constructed URI according to the form described by a particular URI Template. This operation is the (imperfect) inverse of the expansion operation described previously. The matching functionality is provided by the Match method and described in further detail in the Template Matching topic.