UriTemplate.Match(Uri, Uri) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mencoba untuk mencocokkan dengan UriUriTemplate.
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
Alamat dasar.
Mengembalikan
Instans.
Contoh
Contoh berikut menunjukkan cara memanggil Match(Uri, Uri) metode .
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
Keterangan
Jika kecocokan berhasil, UriTemplateMatch diisi dengan segmen URI, nilai variabel, nilai string kueri, dan segmen kartubebas dari URI kandidat. Jika kecocokan tidak berhasil, null
dikembalikan.
Berlaku untuk
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk