UriTemplateMatch.RelativePathSegments 속성

정의

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

public:
 property System::Collections::ObjectModel::Collection<System::String ^> ^ RelativePathSegments { System::Collections::ObjectModel::Collection<System::String ^> ^ get(); };
public System.Collections.ObjectModel.Collection<string> RelativePathSegments { get; }
member this.RelativePathSegments : System.Collections.ObjectModel.Collection<string>
Public ReadOnly Property RelativePathSegments As Collection(Of String)

속성 값

Collection<String>

상대 경로 세그먼트 컬렉션입니다.

예제

다음 코드에서는 RelativePathSegments 속성에 액세스하는 방법을 보여 줍니다.

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)
{
    Console.WriteLine("RelativePathSegments:");
    foreach (string segment in results.RelativePathSegments)
    {
        Console.WriteLine("     {0}", segment);
    }
}
// Code output:
// RelativePathSegments:
//   weather
//   wa
//   seattle
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

    Console.WriteLine("RelativePathSegments:")
    For Each segment As String In results.RelativePathSegments
        Console.WriteLine("      0}", segment)
    Next
End If
'Code output:
'RelativePathSegments:
'  weather
'  wa
'  seattle

설명

이 속성에는 템플릿과 일치한 후보 URI의 경로 세그먼트 및 템플릿 와일드카드와 일치한 경로 세그먼트로 구성된 컬렉션이 포함됩니다. 템플릿 와일드카드와 일치한 경로 세그먼트는 WildcardPathSegments 속성에도 포함되어 있습니다.

적용 대상