本文整理匯總了C#中System.UriTemplateTable.Match方法的典型用法代碼示例。如果您正苦於以下問題:C# UriTemplateTable.Match方法的具體用法?C# UriTemplateTable.Match怎麽用?C# UriTemplateTable.Match使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.UriTemplateTable
的用法示例。
在下文中一共展示了UriTemplateTable.Match方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Uri
Uri prefix = new Uri("http://localhost/");
//Create a series of templates
UriTemplate weatherByCity = new UriTemplate("weather/ state}/ city}");
UriTemplate weatherByCountry = new UriTemplate("weather/ country}/ village}");
UriTemplate weatherByState = new UriTemplate("weather/ state}");
UriTemplate traffic = new UriTemplate("traffic/*");
UriTemplate wildcard = new UriTemplate("*");
//Create a template table
UriTemplateTable table = new UriTemplateTable(prefix);
//Add each template to the table with some associated data
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByCity, "weatherByCity"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByCountry, "weatherByCountry"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByState, "weatherByState"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(traffic, "traffic"));
table.MakeReadOnly(true);
//Call Match to retrieve some match results:
ICollection<UriTemplateMatch> results = null;
Uri weatherInSeattle = new Uri("http://localhost/weather/Washington/Seattle");
results = table.Match(weatherInSeattle);
if( results != null)
{
Console.WriteLine("Matching templates:");
foreach (UriTemplateMatch match in results)
{
Console.WriteLine(" 0}", match.Template);
}
}