UriTemplateMatch.QueryParameters 속성

정의

쿼리 문자열 매개 변수와 해당 값의 컬렉션을 가져옵니다.

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의 모든 쿼리 문자열 이름/값 쌍이 이 컬렉션에 나타납니다. 이 컬렉션에 있는 값은 값의 모든 이스케이프 시퀀스가 실제 문자로 변환됩니다.

적용 대상