UriTemplateMatch.RelativePathSegments Propriété

Définition

Obtient une collection de segments de chemin d'accès relatif.Gets a collection of relative path segments.

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)

Valeur de propriété

Collection<String>

Collection de segments de chemin d'accès relatif.A collection of relative path segments.

Exemples

Le code suivant montre comment accéder à la propriété RelativePathSegments.The following code shows how to access the RelativePathSegments property.

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

Remarques

Cette propriété contient une collection des segments de chemin d’accès de l’URI candidat qui correspondaient au modèle, ainsi que des segments de chemin d’accès qui correspondaient à un caractère générique de modèle.This property contains a collection of the path segments from the candidate URI that matched the template along with path segments that matched a template wildcard. Les segments de chemin d’accès qui correspondaient à un caractère générique de modèle sont également contenus dans la propriété WildcardPathSegments.Path segments that matched a template wildcard are also contained in the WildcardPathSegments property.

S’applique à