本文整理汇总了C#中Parameters.ToQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# Parameters.ToQueryString方法的具体用法?C# Parameters.ToQueryString怎么用?C# Parameters.ToQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameters
的用法示例。
在下文中一共展示了Parameters.ToQueryString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
//http://api.bitcoincharts.com/v1/trades.csv?symbol=mtgoxUSD
public HttpRequestMessage Build() {
var parameters = new Parameters();
parameters.Add("symbol", "{0}{1}".FormatWith(_settings.Market, _settings.Currency));
if(_settings.Start != default(DateTimeOffset)) {
parameters.Add("start", _settings.Start.ToUnixTime());
}
var query = parameters.ToQueryString();
var uri = "v1/trades.csv?{0}".FormatWith(query);
var request = new HttpRequestMessage {
Method = HttpMethod.Get,
RequestUri = new Uri(uri, UriKind.Relative)
};
return request;
}
示例2: ObtainReevooMarkDataInternal
/// <summary>
/// Internal method which does the actual work of getting the Mark data.
/// </summary>
private ReevooMarkData ObtainReevooMarkDataInternal(Parameters params_, String baseUri_)
{
var _builder = new UriBuilder (baseUri_);
_builder.Query = params_.ToQueryString();
//Console.WriteLine ("URL: " + _builder.Uri);
HttpWebRequest _req = (HttpWebRequest)WebRequest.Create (_builder.ToString ());
//Explicitly set the cache level. .NET Framework default is to always bypass the
//cache and go straight to the server. RequestCacheLevel.Default will request cache-control
//and age headers defined in RFC-2616.
var _cachePolicy = new System.Net.Cache.RequestCachePolicy (RequestCacheLevel.Default);
_req.CachePolicy = _cachePolicy;
HttpWebResponse _res = null;
String _content = String.Empty;
try {
//stream web content into a string
try {
_res = (HttpWebResponse)_req.GetResponse ();
} catch (WebException e) {
_res = (HttpWebResponse)e.Response;
}
if( _res.StatusCode == HttpStatusCode.OK){
using (var s = new StreamReader (_res.GetResponseStream ())) {
_content = s.ReadToEnd ();
}
} else {
_content = null;
}
} catch (Exception e_) {
throw new ReevooException (e_);
}
return new ReevooMarkData {
Content = _content,
BestPrice = GetBestPrice (_res.Headers),
ReviewCount = GetReviewCount (_res.Headers),
ScoreCount = GetScoreCount (_res.Headers),
OverallScore = GetOverallScore (_res.Headers),
Sku = params_["sku"],
Retailer = params_["trkref"],
Params = params_,
};
}