UriTemplateMatch 클래스

정의

UriTemplate 인스턴스에 대한 일치 작업의 결과를 나타내는 클래스입니다.

public ref class UriTemplateMatch
public class UriTemplateMatch
type UriTemplateMatch = class
Public Class UriTemplateMatch
상속
UriTemplateMatch

예제

다음 코드에서는 UriTemplateMatch 클래스를 사용하는 방법을 보여 줍니다.

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)
{
    // BaseUri
    Console.WriteLine("BaseUri: {0}", results.BaseUri);

    Console.WriteLine("BoundVariables:");
    foreach (string variableName in results.BoundVariables.Keys)
    {
        Console.WriteLine("    {0}: {1}", variableName, results.BoundVariables[variableName]);
    }

    Console.WriteLine("QueryParameters:");
    foreach (string queryName in results.QueryParameters.Keys)
    {
        Console.WriteLine("    {0} : {1}", queryName, results.QueryParameters[queryName]);
    }
    Console.WriteLine();

    Console.WriteLine("RelativePathSegments:");
    foreach (string segment in results.RelativePathSegments)
    {
        Console.WriteLine("     {0}", segment);
    }
    Console.WriteLine();

    Console.WriteLine("RequestUri:");
    Console.WriteLine(results.RequestUri);

    Console.WriteLine("Template:");
    Console.WriteLine(results.Template);

    Console.WriteLine("WildcardPathSegments:");
    foreach (string segment in results.WildcardPathSegments)
    {
        Console.WriteLine("     {0}", segment);
    }
    Console.WriteLine();
}
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

    'BaseUri
    Console.WriteLine("BaseUri: {0}", results.BaseUri)

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

    Console.WriteLine("QueryParameters:")
    For Each queryName As String In results.QueryParameters.Keys
        Console.WriteLine("    {0} : {1}", queryName, results.QueryParameters(queryName))
    Next
    Console.WriteLine()

    Console.WriteLine("RelativePathSegments:")
    For Each segment As String In results.RelativePathSegments
        Console.WriteLine("     {0}", segment)
    Next
    Console.WriteLine()

    Console.WriteLine("RequestUri:")
    Console.WriteLine(results.RequestUri)

    Console.WriteLine("Template:")
    Console.WriteLine(results.Template)

    Console.WriteLine("WildcardPathSegments:")
    For Each segment As String In results.WildcardPathSegments
        Console.WriteLine("     {0}", segment)
    Next
    Console.WriteLine()
End If

설명

UriTemplateMatch 클래스는 Match(Uri, Uri) 메서드 호출 결과를 나타냅니다. 이 클래스는 스레드로부터 안전하지 않습니다.

생성자

UriTemplateMatch()

UriTemplateMatch 클래스의 새 인스턴스를 초기화합니다.

속성

BaseUri

템플릿 일치를 위한 기본 URI를 가져오거나 설정합니다.

BoundVariables

템플릿 일치를 위한 BoundVariables 컬렉션을 가져옵니다.

Data

UriTemplateMatch 인스턴스와 연결된 개체를 가져오거나 설정합니다.

QueryParameters

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

RelativePathSegments

상대 경로 세그먼트 컬렉션을 가져옵니다.

RequestUri

일치하는 URI를 가져오거나 설정합니다.

Template

UriTemplateMatch 인스턴스와 연결된 UriTemplate 인스턴스를 가져오거나 설정합니다.

WildcardPathSegments

URI 템플릿에서 와일드카드와 일치하는 경로 세그먼트 컬렉션을 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상