UriTemplate.BindByName UriTemplate.BindByName UriTemplate.BindByName UriTemplate.BindByName Method

定义

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

重载

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

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

BindByName(Uri, NameValueCollection) BindByName(Uri, NameValueCollection) BindByName(Uri, NameValueCollection) BindByName(Uri, NameValueCollection)

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

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

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

BindByName(Uri, NameValueCollection, Boolean) BindByName(Uri, NameValueCollection, Boolean) BindByName(Uri, NameValueCollection, Boolean) BindByName(Uri, NameValueCollection, Boolean)

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

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

Creates a new URI from the template and the collection of parameters.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

参数

baseAddress
Uri Uri Uri Uri

The base address.The base address.

parameters
IDictionary<String,String>

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

返回

A URI.A URI.

注解

IDictionary<字符串、 字符串 >参数包含参数名称和值对的集合。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.

备注

传递给此方法的名称/值集合必须包含每个模板变量的键值。The name/value collection passed to this method must contain a key for every template variable. 与模板变量不匹配的额外名称/值对会追加到最终 URI 的查询字符串之后。Extra name/value pairs that do not match template variables are appended to the query string of the final URI.

重要

您可以在名称/值对中传入文本,以阻止生成的 URI 与用于生成它的模板匹配。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 '}'.

BindByName(Uri, NameValueCollection) BindByName(Uri, NameValueCollection) BindByName(Uri, NameValueCollection) BindByName(Uri, NameValueCollection)

Creates a new URI from the template and the collection of parameters.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

参数

baseAddress
Uri Uri Uri Uri

The base address.The base address.

parameters
NameValueCollection NameValueCollection NameValueCollection NameValueCollection

The parameter values.The parameter values.

返回

A new instance.A new instance.

示例

下面的示例演示如何调用 BindByName(Uri, NameValueCollection) 方法。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)

注解

NameValueCollection 参数包含参数名称/值对的集合。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.

备注

传递给 BindByName(Uri, NameValueCollection) 的名称/值集合必须包含每个模板变量的键值。The name/value collection passed to BindByName(Uri, NameValueCollection) must contain a key for every template variable. 与模板变量不匹配的额外名称/值对会追加到最终 URI 的查询字符串之后。Extra name/value pairs that do not match template variables are appended to the query string of the final URI.

备注

您可以在名称/值对中传入文本,以阻止生成的 URI 与用于生成它的模板匹配。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 '}'.

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

Creates a new URI from the template and the collection of parameters.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

参数

baseAddress
Uri Uri Uri Uri

A URI that contains the base address.A URI that contains the base address.

parameters
IDictionary<String,String>

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

omitDefaults
Boolean Boolean Boolean Boolean

true is the default values are ignored; otherwise false.true is the default values are ignored; otherwise false.

返回

A URI.A URI.

BindByName(Uri, NameValueCollection, Boolean) BindByName(Uri, NameValueCollection, Boolean) BindByName(Uri, NameValueCollection, Boolean) BindByName(Uri, NameValueCollection, Boolean)

Creates a new URI from the template and the collection of parameters.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

参数

baseAddress
Uri Uri Uri Uri

The base address.The base address.

parameters
NameValueCollection NameValueCollection NameValueCollection NameValueCollection

A collection of parameter name/value pairs.A collection of parameter name/value pairs.

omitDefaults
Boolean Boolean Boolean Boolean

true if the default values are ignored; otherwise false.true if the default values are ignored; otherwise false.

返回

A URI.A URI.

适用于