UriTemplateTable.KeyValuePairs 속성

정의

UriTemplate 개체 및 연결된 데이터로 구성된 키/값 쌍 컬렉션을 가져옵니다.Gets a collection of key/value pairs that consist of UriTemplate objects and their associated data.

public:
 property System::Collections::Generic::IList<System::Collections::Generic::KeyValuePair<UriTemplate ^, System::Object ^>> ^ KeyValuePairs { System::Collections::Generic::IList<System::Collections::Generic::KeyValuePair<UriTemplate ^, System::Object ^>> ^ get(); };
public System.Collections.Generic.IList<System.Collections.Generic.KeyValuePair<UriTemplate,object>> KeyValuePairs { get; }
member this.KeyValuePairs : System.Collections.Generic.IList<System.Collections.Generic.KeyValuePair<UriTemplate, obj>>
Public ReadOnly Property KeyValuePairs As IList(Of KeyValuePair(Of UriTemplate, Object))

속성 값

UriTemplate 개체 및 연결된 데이터로 구성된 키/값 쌍 컬렉션입니다.A collection of key/value pairs that consist of UriTemplate objects and their associated data.

예제

다음 예제에서는 KeyValuePairs 속성에 액세스하는 방법을 보여 줍니다.The following example shows how to access the KeyValuePairs property.

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("     0},  1}", keyPair.Key, keyPair.Value);
}

Console.WriteLine();
Dim prefix As New Uri("http://localhost/")

' Create a series of templates
Dim weatherByCity = New UriTemplate("weather/ state}/ city}")
Dim weatherByCountry = New UriTemplate("weather/ country}/ village}")
Dim weatherByState = New UriTemplate("weather/ state}")
Dim traffic = New UriTemplate("traffic/*")
Dim wildcard = 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()

설명

테이블의 각 UriTemplate 인스턴스에는 연결된 데이터가 있습니다.Each UriTemplate instance in the table has data associated with it. KeyValuePairs 속성은 키/값 쌍 컬렉션을 포함하며, 여기서 키는 UriTemplate 인스턴스이고 값은 UriTemplate과 연결된 데이터입니다.The KeyValuePairs property contains a collection of key value pairs where the key is a UriTemplate instance and the value is the data associated with the UriTemplate. 값은 KeyValuePairs, MakeReadOnly(Boolean) 또는 Match(Uri)을 호출하기 전에만 MatchSingle(Uri) 속성에 추가할 수 있습니다. 그렇지 않으면 NotSupportedException이 throw됩니다.Values can only be added to KeyValuePairs property prior to calling MakeReadOnly(Boolean) or Match(Uri) or MatchSingle(Uri) otherwise a NotSupportedException is thrown.

적용 대상