Bagikan melalui


UriTemplateMatch.QueryParameters Properti

Definisi

Mendapatkan kumpulan parameter string kueri dan nilainya.

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

Nilai Properti

NameValueCollection Instans yang berisi parameter string kueri dan nilainya.

Contoh

Kode berikut menunjukkan cara mengakses QueryParameters properti.

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

Keterangan

Semua pasangan nama/nilai string kueri dari URI asli muncul dalam koleksi ini, meskipun tidak ditentukan secara eksplisit dalam string templat yang cocok. Nilai dalam koleksi ini telah memiliki semua urutan escape yang diterjemahkan ke dalam karakter aktual.

Berlaku untuk