UriTemplate.Match(Uri, Uri) 메서드

정의

에 대한 일치 Uri 를 시도합니다 UriTemplate.

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 템플릿과 일치하는 항목입니다.

반품

인스턴스입니다.

예제

다음 예제에서는 메서드를 호출 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 하면 반환됩니다.

적용 대상