本文整理匯總了C#中System.UriBuilder.AddQuery方法的典型用法代碼示例。如果您正苦於以下問題:C# UriBuilder.AddQuery方法的具體用法?C# UriBuilder.AddQuery怎麽用?C# UriBuilder.AddQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.UriBuilder
的用法示例。
在下文中一共展示了UriBuilder.AddQuery方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ToBcd_Test
public void ToBcd_Test()
{
UriBuilder uri = new UriBuilder("http://a/b/c");
uri = uri.AddQuery("name", "z");
Assert.AreEqual("http://a:80/b/c?name=z", uri.ToString());
uri = uri.AddQuery("age", "12");
Assert.AreEqual("http://a:80/b/c?name=z&age=12", uri.ToString());
}
示例2: TrimUrlParameters
public void TrimUrlParameters()
{
UriBuilder uri = new UriBuilder(Uri);
if (Parameters != null)
foreach (var webParameter in Parameters.ToList().Where(x => x.ParameterType == WebParameterType.Url))
{
uri.AddQuery(webParameter.Name, webParameter.Value);
Parameters.Remove(webParameter);
}
}
示例3: CreateContactSummaryListRequest
private static HttpRequestMessage CreateContactSummaryListRequest(IAccount account, DateTime lastUpdated)
{
var requestUriBuilder = new UriBuilder("https://api.linkedin.com/v1/people/~/connections");
requestUriBuilder.AddQuery("oauth2_access_token", HttpUtility.UrlEncode(account.CurrentSession.AccessToken));
if (lastUpdated != default(DateTime))
{
var lastModifedAsUnixTimestamp =
(lastUpdated - UnixEpoch).TotalMilliseconds.ToString(CultureInfo.InvariantCulture)
.Split('.')
.First();
requestUriBuilder.AddQuery("modified", "updated")
.AddQuery("modified-since", lastModifedAsUnixTimestamp);
}
var request = new HttpRequestMessage(HttpMethod.Get, requestUriBuilder.Uri);
request.Headers.Add("x-li-format", "json");
return request;
}