UriTemplate.Match(Uri, Uri) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Versucht, eine Uri Übereinstimmung mit einem .UriTemplate
public:
UriTemplateMatch ^ Match(Uri ^ baseAddress, Uri ^ candidate);
public UriTemplateMatch Match(Uri baseAddress, Uri candidate);
member this.Match : Uri * Uri -> UriTemplateMatch
Public Function Match (baseAddress As Uri, candidate As Uri) As UriTemplateMatch
Parameter
- baseAddress
- Uri
Die Basisadresse.
Gibt zurück
Eine Instanz.
Beispiele
Im folgenden Beispiel wird gezeigt, wie die Match(Uri, Uri) -Methode aufgerufen wird.
UriTemplate template = new UriTemplate("weather/{state}/{city}?forecast={day}");
Uri prefix = new Uri("http://localhost");
Uri fullUri = new Uri("http://localhost/weather/Washington/Redmond?forecast=today");
UriTemplateMatch results = template.Match(prefix, fullUri);
Console.WriteLine("Matching {0} to {1}", template.ToString(), fullUri.ToString());
if (results != null)
{
foreach (string variableName in results.BoundVariables.Keys)
{
Console.WriteLine(" {0}: {1}", variableName, results.BoundVariables[variableName]);
}
}
Dim template As UriTemplate = New UriTemplate("weather/{state}/{city}?forecast={day}")
Dim prefix As Uri = New Uri("http://localhost")
Dim fullUri As Uri = New Uri("http://localhost/weather/Washington/Redmond?forecast=today")
Dim results As UriTemplateMatch = template.Match(prefix, fullUri)
Console.WriteLine("Matching {0} to {1}", template.ToString(), fullUri.ToString())
If results IsNot Nothing Then
For Each variableName As String In results.BoundVariables.Keys
Console.WriteLine(" {0}: {1}", variableName, results.BoundVariables(variableName))
Next
End If
Hinweise
Wenn die Übereinstimmung erfolgreich ist, werden die UriTemplateMatch URI-Segmente, Variablenwerte, Abfragezeichenfolgenwerte und Wildcardsegmente aus dem Kandidaten-URI aufgefüllt. Wenn die Übereinstimmung nicht erfolgreich ist, null wird sie zurückgegeben.