UriTemplateTable 클래스

정의

UriTemplate 개체의 연결 세트를 나타내는 클래스입니다.

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

예제

다음 코드에서는 UriTemplateTable을 만들고 이를 채우며 후보 Uri와 일치시키는 방법을 보여 줍니다.

Uri prefix = new Uri("http://localhost/");

//Create a series of templates
UriTemplate weatherByCity  = new UriTemplate("weather/{state}/{city}");
UriTemplate weatherByCountry = new UriTemplate("weather/{country}/{village}");
UriTemplate weatherByState = new UriTemplate("weather/{state}");
UriTemplate traffic = new UriTemplate("traffic/*");
UriTemplate wildcard = new UriTemplate("*");

//Create a template table
UriTemplateTable table = new UriTemplateTable(prefix);
//Add each template to the table with some associated data
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByCity, "weatherByCity"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByCountry, "weatherByCountry"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByState, "weatherByState"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(traffic, "traffic"));

table.MakeReadOnly(true);
Console.WriteLine("KeyValuePairs:");
foreach (KeyValuePair<UriTemplate, Object> keyPair in table.KeyValuePairs)
{
    Console.WriteLine($"{keyPair.Key}, {keyPair.Value}");
}

Console.WriteLine();

//Call MatchSingle to retrieve some match results:
ICollection<UriTemplateMatch> results = null;
Uri weatherInSeattle = new Uri("http://localhost/weather/Washington/Seattle");

results = table.Match(weatherInSeattle);
if( results != null)
{
    Console.WriteLine("Matching templates:");
    foreach (UriTemplateMatch match in results)
    {
        Console.WriteLine(match.Template);
    }
}
Dim prefix As New Uri("http://localhost/")

' Create a series of templates
Dim weatherByCity As New UriTemplate("weather/ state}/ city}")
Dim weatherByCountry As New UriTemplate("weather/ country}/ village}")
Dim weatherByState As New UriTemplate("weather/ state}")
Dim traffic As New UriTemplate("traffic/*")
Dim wildcard As New UriTemplate("*")

' Create a template table
Dim table As New UriTemplateTable(prefix)
' Add each template to the table with some associated data
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByCity, "weatherByCity"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByCountry, "weatherByCountry"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByState, "weatherByState"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(traffic, "traffic"))

table.MakeReadOnly(True)
Console.WriteLine("KeyValuePairs:")
For Each keyPair As KeyValuePair(Of UriTemplate, Object) In table.KeyValuePairs
    Console.WriteLine("     0},  1}", keyPair.Key, keyPair.Value)
Next

Console.WriteLine()

' Call MatchSingle to retrieve some match results:
Dim results As System.Collections.Generic.ICollection(Of UriTemplateMatch) = Nothing
Dim weatherInSeattle As Uri = New Uri("http://localhost/weather/Washington/Seattle")

results = table.Match(weatherInSeattle)
If results IsNot Nothing Then
    Console.WriteLine("Matching templates:")
    For Each match As UriTemplateMatch In results
        Console.WriteLine("    0}", match.Template)
    Next
End If

설명

UriTemplateTable은 개발자가 선택한 개체에 바인딩된 UriTemplate 개체의 연결 세트입니다. 후보 URI(Uniform Resource Identifier)를 세트의 템플릿에 일치시키고 일치하는 템플릿과 연결된 데이터를 검색할 수 있습니다. UriTemplateTable의 내용은 MakeReadOnly(Boolean) 메서드가 호출되기 전까지 변경할 수 있으며, 메서드가 호출되면 다음 형식의 유효성 검사 중 하나가 실시됩니다.

  • MakeReadOnly(Boolean)가 호출되어 false를 전달하면 UriTemplateTable은 테이블에 구조상 동등한 템플릿이 여러 개가 없음을 확인하기 위해 검사합니다. 그러한 템플릿이 있는 경우 예외를 throw합니다. 이 형식의 유효성 검사는 단 하나의 템플릿이 들어오는 URI와 일치하도록 하려는 경우에 MatchSingle(Uri)과 함께 사용합니다.

  • MakeReadOnly(Boolean)가 호출되어 true를 전달하면 구조상 동등한 템플릿 여러 개가 UriTemplateTable에 포함될 수 있습니다. 그러나 템플릿 내의 쿼리 문자열은 모호해서는 안 됩니다. 동일한 쿼리 문자열은 허용됩니다. 모호한 쿼리 문자열에 대 한 자세한 내용은 참조 하세요. UriTemplate 및 UriTemplateTable합니다.

생성자

UriTemplateTable()

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

UriTemplateTable(IEnumerable<KeyValuePair<UriTemplate,Object>>)

지정된 키/값 쌍 컬렉션을 사용하여 UriTemplateTable 클래스의 새 인스턴스를 초기화합니다.

UriTemplateTable(Uri)

지정된 기본 주소를 사용하여 UriTemplateTable 클래스의 새 인스턴스를 초기화합니다.

UriTemplateTable(Uri, IEnumerable<KeyValuePair<UriTemplate,Object>>)

지정된 기본 주소 및 키/값 쌍 컬렉션을 사용하여 UriTemplateTable 클래스의 새 인스턴스를 초기화합니다.

속성

BaseAddress

UriTemplateTable 인스턴스의 기본 주소를 가져오거나 설정합니다.

IsReadOnly

UriTemplateTable이 읽기 전용인지 여부를 지정하는 값을 가져옵니다.

KeyValuePairs

UriTemplate 개체 및 연결된 데이터로 구성된 키/값 쌍 컬렉션을 가져옵니다.

OriginalBaseAddress

원래 기본 주소를 가져옵니다.

메서드

Equals(Object)

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

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

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

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

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

(다음에서 상속됨 Object)
MakeReadOnly(Boolean)

UriTemplateTable을 읽기 전용으로 만듭니다.

Match(Uri)

후보 UriUriTemplateTable과 일치시키려고 시도합니다.

MatchSingle(Uri)

후보 UriUriTemplateTable과 일치시키려고 시도합니다.

MemberwiseClone()

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

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

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

(다음에서 상속됨 Object)

적용 대상