Compartir vía


UriTemplateMatch.QueryParameters Propiedad

Definición

Obtiene una colección de parámetros de cadena de consulta y sus valores.

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

Valor de propiedad

Instancia NameValueCollection de que contiene los parámetros de cadena de consulta y sus valores.

Ejemplos

En el código siguiente se muestra cómo acceder a la QueryParameters propiedad .

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

Comentarios

Todos los pares de nombre y valor de la cadena de consulta del URI original aparecen en esta colección, incluso si no se especifican explícitamente en la cadena de plantilla que coincida. Los valores de esta colección se han tenido todas las secuencias de escape traducidas a caracteres reales.

Se aplica a