UriTemplateMatch Sınıf

Tanım

Bir örnekteki eşleştirme işleminin sonuçlarını temsil eden bir UriTemplate sınıf.

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

Örnekler

Aşağıdaki kodda sınıfın nasıl kullanılacağı gösterilmektedir UriTemplateMatch .

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

Açıklamalar

sınıfı, UriTemplateMatch yöntemini çağırmanın Match(Uri, Uri) sonuçlarını temsil eder. Bu sınıf iş parçacığı güvenli değil.

Oluşturucular

Name Description
UriTemplateMatch()

UriTemplateMatch sınıfının yeni bir örneğini başlatır.

Özellikler

Name Description
BaseUri

Şablon eşleşmesi için temel URI'yi alır veya ayarlar.

BoundVariables

Şablon eşleşmesi BoundVariables için koleksiyonu alır.

Data

Örnekle UriTemplateMatch ilişkili nesneyi alır veya ayarlar.

QueryParameters

Sorgu dizesi parametrelerinin ve değerlerinin bir koleksiyonunu alır.

RelativePathSegments

Göreli yol kesimlerinden oluşan bir koleksiyon alır.

RequestUri

Eşleşen URI'yi alır veya ayarlar.

Template

Bu UriTemplate örnekle ilişkili örneği alır veya ayarlarUriTemplateMatch.

WildcardPathSegments

URI şablonundaki joker karakterle eşleşen yol kesimleri koleksiyonunu alır.

Yöntemler

Name Description
Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Geçerli örneğin Type alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden bir dize döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır