UriTemplateMatch.QueryParameters 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得一組查詢字串參數及其值。
public:
property System::Collections::Specialized::NameValueCollection ^ QueryParameters { System::Collections::Specialized::NameValueCollection ^ get(); };
public System.Collections.Specialized.NameValueCollection QueryParameters { get; }
member this.QueryParameters : System.Collections.Specialized.NameValueCollection
Public ReadOnly Property QueryParameters As NameValueCollection
屬性值
一個 NameValueCollection 包含查詢字串參數及其值的實例。
範例
以下代碼說明如何進入該 QueryParameters 物業。
UriTemplate template = new UriTemplate("weather/{state}/{city}?forecast=today");
Uri baseAddress = new Uri("http://localhost");
Uri fullUri = new Uri("http://localhost/weather/WA/Seattle?forecast=today");
Console.WriteLine("Matching {0} to {1}", template.ToString(), fullUri.ToString());
// Match a URI to a template
UriTemplateMatch results = template.Match(baseAddress, fullUri);
if (results != null)
{
Console.WriteLine("QueryParameters:");
foreach (string queryName in results.QueryParameters.Keys)
{
Console.WriteLine(" {0} : {1}", queryName, results.QueryParameters[queryName]);
}
Console.WriteLine();
}
// Code output:
// QueryParameters:
// forecast : today
Dim template As New UriTemplate("weather/ state}/ city}?forecast=today")
Dim baseAddress As New Uri("http://localhost")
Dim fullUri As New Uri("http://localhost/weather/WA/Seattle?forecast=today")
Console.WriteLine("Matching 0} to 1}", template.ToString(), fullUri.ToString())
'Match a URI to a template
Dim results As UriTemplateMatch = template.Match(baseAddress, fullUri)
If (results IsNot Nothing) Then
Console.WriteLine("QueryParameters:")
For Each queryName As String In results.QueryParameters.Keys
Console.WriteLine(" 0} : 1}", queryName, results.QueryParameters(queryName))
Next
Console.WriteLine()
End If
'Code output:
' QueryParameters:
' forecast : today
備註
原始 URI 中的所有查詢字串名稱/值對都會出現在這個集合中,即使這些對應的範本字串中沒有明確指定。 本集合中的數值已將所有逃脫序列轉換為實際字元。