UriTemplate.Match(Uri, Uri) 메서드

정의

UriUriTemplate과 일치시키려고 시도합니다.

public:
 UriTemplateMatch ^ Match(Uri ^ baseAddress, Uri ^ candidate);
public UriTemplateMatch Match (Uri baseAddress, Uri candidate);
member this.Match : Uri * Uri -> UriTemplateMatch
Public Function Match (baseAddress As Uri, candidate As Uri) As UriTemplateMatch

매개 변수

baseAddress
Uri

기본 주소입니다.

candidate
Uri

템플릿과 일치시킬 Uri입니다.

반환

UriTemplateMatch

인스턴스입니다.

예제

다음 예제에서는 Match(Uri, Uri) 메서드를 호출하는 방법을 보여 줍니다.

UriTemplate template = new UriTemplate("weather/{state}/{city}?forecast={day}");
Uri prefix = new Uri("http://localhost");

Uri fullUri = new Uri("http://localhost/weather/Washington/Redmond?forecast=today");
UriTemplateMatch results = template.Match(prefix, fullUri);

Console.WriteLine("Matching {0} to {1}", template.ToString(), fullUri.ToString());

if (results != null)
{
    foreach (string variableName in results.BoundVariables.Keys)
    {
        Console.WriteLine("   {0}: {1}", variableName, results.BoundVariables[variableName]);
    }
}
Dim template As UriTemplate = New UriTemplate("weather/{state}/{city}?forecast={day}")
Dim prefix As Uri = New Uri("http://localhost")

Dim fullUri As Uri = New Uri("http://localhost/weather/Washington/Redmond?forecast=today")
Dim results As UriTemplateMatch = template.Match(prefix, fullUri)

Console.WriteLine("Matching {0} to {1}", template.ToString(), fullUri.ToString())

If results IsNot Nothing Then
    For Each variableName As String In results.BoundVariables.Keys
        Console.WriteLine("   {0}: {1}", variableName, results.BoundVariables(variableName))
    Next
End If

설명

일치가 성공적으로 수행되면 UriTemplateMatch에 후보 URI의 URI 세그먼트, 변수 값, 쿼리 문자열 값 및 와일드카드 세그먼트가 채워집니다. 일치시키지 못하면 null이 반환됩니다.

적용 대상