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());
        }
Esempio n. 2
0
 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);
         }
 }
        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;
        }