UriTemplateMatch.QueryParameters Vlastnost

Definice

Získá kolekci parametrů řetězce dotazu a jejich hodnot.

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

Hodnota vlastnosti

Instance NameValueCollection , která obsahuje parametry řetězce dotazu a jejich hodnoty.

Příklady

Následující kód ukazuje, jak získat přístup QueryParameters k vlastnosti.

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

Poznámky

V této kolekci se zobrazí všechny páry název/hodnota řetězce dotazu z původního identifikátoru URI, i když nejsou explicitně zadány v řetězci šablony, který byl zadán. Hodnoty v této kolekci byly všechny řídicí sekvence přeloženy na skutečné znaky.

Platí pro