UriTemplateMatch Klasa

Definicja

Klasa reprezentująca wyniki operacji dopasowania w wystąpieniu UriTemplate .

public ref class UriTemplateMatch
public class UriTemplateMatch
type UriTemplateMatch = class
Public Class UriTemplateMatch
Dziedziczenie
UriTemplateMatch

Przykłady

Poniższy kod pokazuje, jak używać UriTemplateMatch klasy.

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)
{
    // BaseUri
    Console.WriteLine("BaseUri: {0}", results.BaseUri);

    Console.WriteLine("BoundVariables:");
    foreach (string variableName in results.BoundVariables.Keys)
    {
        Console.WriteLine("    {0}: {1}", variableName, results.BoundVariables[variableName]);
    }

    Console.WriteLine("QueryParameters:");
    foreach (string queryName in results.QueryParameters.Keys)
    {
        Console.WriteLine("    {0} : {1}", queryName, results.QueryParameters[queryName]);
    }
    Console.WriteLine();

    Console.WriteLine("RelativePathSegments:");
    foreach (string segment in results.RelativePathSegments)
    {
        Console.WriteLine("     {0}", segment);
    }
    Console.WriteLine();

    Console.WriteLine("RequestUri:");
    Console.WriteLine(results.RequestUri);

    Console.WriteLine("Template:");
    Console.WriteLine(results.Template);

    Console.WriteLine("WildcardPathSegments:");
    foreach (string segment in results.WildcardPathSegments)
    {
        Console.WriteLine("     {0}", segment);
    }
    Console.WriteLine();
}
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

    'BaseUri
    Console.WriteLine("BaseUri: {0}", results.BaseUri)

    Console.WriteLine("BoundVariables:")
    For Each variableName As String In results.BoundVariables.Keys
        Console.WriteLine("    {0}: {1}", variableName, results.BoundVariables(variableName))
    Next

    Console.WriteLine("QueryParameters:")
    For Each queryName As String In results.QueryParameters.Keys
        Console.WriteLine("    {0} : {1}", queryName, results.QueryParameters(queryName))
    Next
    Console.WriteLine()

    Console.WriteLine("RelativePathSegments:")
    For Each segment As String In results.RelativePathSegments
        Console.WriteLine("     {0}", segment)
    Next
    Console.WriteLine()

    Console.WriteLine("RequestUri:")
    Console.WriteLine(results.RequestUri)

    Console.WriteLine("Template:")
    Console.WriteLine(results.Template)

    Console.WriteLine("WildcardPathSegments:")
    For Each segment As String In results.WildcardPathSegments
        Console.WriteLine("     {0}", segment)
    Next
    Console.WriteLine()
End If

Uwagi

Klasa UriTemplateMatch reprezentuje wyniki wywoływania Match(Uri, Uri) metody. Ta klasa nie jest bezpieczna wątkiem.

Konstruktory

UriTemplateMatch()

Inicjuje nowe wystąpienie klasy UriTemplateMatch.

Właściwości

BaseUri

Pobiera lub ustawia podstawowy identyfikator URI dla dopasowania szablonu.

BoundVariables

BoundVariables Pobiera kolekcję dla dopasowania szablonu.

Data

Pobiera lub ustawia obiekt skojarzony z wystąpieniem UriTemplateMatch .

QueryParameters

Pobiera kolekcję parametrów ciągu zapytania i ich wartości.

RelativePathSegments

Pobiera kolekcję segmentów ścieżki względnej.

RequestUri

Pobiera lub ustawia zgodny identyfikator URI.

Template

Pobiera lub ustawia UriTemplate wystąpienie skojarzone z tym UriTemplateMatch wystąpieniem.

WildcardPathSegments

Pobiera kolekcję segmentów ścieżki pasujących do symbolu wieloznakowego w szablonie identyfikatora URI.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy