Upravit

Sdílet prostřednictvím


UriTemplate.BindByName Method

Definition

Creates a new URI from the template and the collection of parameters.

Overloads

BindByName(Uri, IDictionary<String,String>)

Creates a new URI from the template and the collection of parameters.

BindByName(Uri, NameValueCollection)

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.

BindByName(Uri, NameValueCollection, Boolean)

Creates a new URI from the template and the collection of parameters.

BindByName(Uri, IDictionary<String,String>)

Creates a new URI from the template and the collection of parameters.

public:
 Uri ^ BindByName(Uri ^ baseAddress, System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ parameters);
public Uri BindByName (Uri baseAddress, System.Collections.Generic.IDictionary<string,string> parameters);
member this.BindByName : Uri * System.Collections.Generic.IDictionary<string, string> -> Uri
Public Function BindByName (baseAddress As Uri, parameters As IDictionary(Of String, String)) As Uri

Parameters

baseAddress
Uri

The base address.

parameters
IDictionary<String,String>

A dictionary that contains a collection of parameter name/value pairs.

Returns

Uri

A URI.

Remarks

The IDictionary<string,string> parameter contains a collection of parameter name and value pairs. The parameters are matched up against the variables within the template by a case-insensitive comparison.

Note

The name/value collection passed to this method must contain a key for every template variable. Extra name/value pairs that do not match template variables are appended to the query string of the final URI.

Important

It is possible to pass in text within the name/value pairs that prevent the generated URI from matching the template that is used to generate it. Examples of such text includes: '/', '..', '*', '{', and '}'.

Applies to

BindByName(Uri, NameValueCollection)

Creates a new URI from the template and the collection of parameters.

public:
 Uri ^ BindByName(Uri ^ baseAddress, System::Collections::Specialized::NameValueCollection ^ parameters);
public Uri BindByName (Uri baseAddress, System.Collections.Specialized.NameValueCollection parameters);
member this.BindByName : Uri * System.Collections.Specialized.NameValueCollection -> Uri
Public Function BindByName (baseAddress As Uri, parameters As NameValueCollection) As Uri

Parameters

baseAddress
Uri

The base address.

parameters
NameValueCollection

The parameter values.

Returns

Uri

A new instance.

Examples

The following example shows how to call the BindByName(Uri, NameValueCollection) method.

UriTemplate template = new UriTemplate("weather/{state}/{city}?forecast={day}");
Uri prefix = new Uri("http://localhost");

NameValueCollection parameters = new NameValueCollection();
parameters.Add("state", "Washington");
parameters.Add("city", "Redmond");
parameters.Add("day", "Today");
Uri namedUri = template.BindByName(prefix, parameters);
Dim template As UriTemplate = New UriTemplate("weather/{state}/{city}?forecast={day}")
Dim prefix As Uri = New Uri("http://localhost")

Dim parameters As NameValueCollection = New NameValueCollection()
parameters.Add("state", "Washington")
parameters.Add("city", "Redmond")
parameters.Add("day", "Today")
Dim namedUri As Uri = template.BindByName(prefix, parameters)

Remarks

The NameValueCollection parameter contains a collection of parameter name/value pairs. The parameters are matched up against the variables within the template by a case-insensitive comparison. Values passed in this collection are escaped.

Note

The name/value collection passed to BindByName(Uri, NameValueCollection) must contain a key for every template variable. Extra name/value pairs that do not match template variables are appended to the query string of the final URI.

Note

It is possible to pass in text within the name/value pairs that prevent the generated URI from matching the template that is used to generate it. Examples of such text includes: '/', '..', '*', '{', and '}'.

Applies to

BindByName(Uri, IDictionary<String,String>, Boolean)

Creates a new URI from the template and the collection of parameters.

public:
 Uri ^ BindByName(Uri ^ baseAddress, System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ parameters, bool omitDefaults);
public Uri BindByName (Uri baseAddress, System.Collections.Generic.IDictionary<string,string> parameters, bool omitDefaults);
member this.BindByName : Uri * System.Collections.Generic.IDictionary<string, string> * bool -> Uri
Public Function BindByName (baseAddress As Uri, parameters As IDictionary(Of String, String), omitDefaults As Boolean) As Uri

Parameters

baseAddress
Uri

A URI that contains the base address.

parameters
IDictionary<String,String>

A dictionary that contains a collection of parameter name/value pairs.

omitDefaults
Boolean

true is the default values are ignored; otherwise false.

Returns

Uri

A URI.

Applies to

BindByName(Uri, NameValueCollection, Boolean)

Creates a new URI from the template and the collection of parameters.

public:
 Uri ^ BindByName(Uri ^ baseAddress, System::Collections::Specialized::NameValueCollection ^ parameters, bool omitDefaults);
public Uri BindByName (Uri baseAddress, System.Collections.Specialized.NameValueCollection parameters, bool omitDefaults);
member this.BindByName : Uri * System.Collections.Specialized.NameValueCollection * bool -> Uri
Public Function BindByName (baseAddress As Uri, parameters As NameValueCollection, omitDefaults As Boolean) As Uri

Parameters

baseAddress
Uri

The base address.

parameters
NameValueCollection

A collection of parameter name/value pairs.

omitDefaults
Boolean

true if the default values are ignored; otherwise false.

Returns

Uri

A URI.

Applies to