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

설명

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

  • MakeReadOnly(Boolean) 전달 falseUriTemplateTable 이라고 하면 테이블에 구조적으로 동등한 템플릿이 여러 개 포함되어 있지 않은지 확인합니다. 이러한 템플릿을 찾으면 예외가 throw됩니다. 이 유형의 유효성 검사는 하나의 템플릿만 들어오는 URI와 일치하는지 확인하려는 경우와 MatchSingle(Uri) 함께 사용됩니다.

  • 전달MakeReadOnly(Boolean)이라고 하는 경우 true 구조적으로 동등한 여러 템플릿을 에 포함UriTemplateTable할 수 있습니다. 그러나 템플릿의 쿼리 문자열은 모호하지 않아야 합니다. 동일한 쿼리 문자열이 허용됩니다. 모호한 쿼리 문자열에 대한 자세한 내용은 UriTemplate 및 UriTemplateTable을 참조하세요.

생성자

Name Description
UriTemplateTable()

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

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

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

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

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

UriTemplateTable(Uri)

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

속성

Name Description
BaseAddress

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

IsReadOnly

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

KeyValuePairs

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

OriginalBaseAddress

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

메서드

Name Description
Equals(Object)

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

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

기본 해시 함수로 사용됩니다.

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

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

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

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

Match(Uri)

후보 Uri 와 일치시키려고 시도합니다 UriTemplateTable.

MatchSingle(Uri)

후보 Uri 와 일치시키려고 시도합니다 UriTemplateTable.

MemberwiseClone()

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

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

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

(다음에서 상속됨 Object)

적용 대상