本文整理汇总了C#中HttpHelper.OpenRead方法的典型用法代码示例。如果您正苦于以下问题:C# HttpHelper.OpenRead方法的具体用法?C# HttpHelper.OpenRead怎么用?C# HttpHelper.OpenRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpHelper
的用法示例。
在下文中一共展示了HttpHelper.OpenRead方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStringFrom
private static string GetStringFrom(string url)
{
var helper = new HttpHelper(url);
helper.HttpWebRequest.AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate;
helper.HttpWebRequest.Proxy = null;
helper.HttpWebRequest.ServicePoint.ConnectionLimit = Int32.MaxValue;
helper.HttpWebRequest.ContentType = "text/html; charset=utf-8";
using (var stream = helper.OpenRead())
{
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
示例2: IsNugetAvailable
/// <summary>
/// Checks if there is a Nuget avilable for the repository with the specified <paramref name="name"/>
/// </summary>
/// <param name="name">The name of the repository.</param>
/// <returns><see langword="true" /> if there is a Nuget available, otherwise <see langword="false" />.</returns>
public bool IsNugetAvailable(string name)
{
var url =
string.Format(@" http://nuget.org/api/v2/Packages?$filter=Id%20eq%20'{0}'", name);
var client =
new HttpHelper(url);
using (var stream = client.OpenRead())
{
using (var reader = new StreamReader(stream))
{
var content =
reader.ReadToEnd();
return content.IndexOf("<entry>", StringComparison.OrdinalIgnoreCase) >= 0;
}
}
}
示例3: RetrieveResponse
private dynamic RetrieveResponse(string url)
{
var httpHelper =
new HttpHelper(url);
using (var stream = httpHelper.OpenRead())
{
using (var reader = new StreamReader(stream))
{
var json =
reader.ReadToEnd();
var result =
SimpleJson.DeserializeObject(json);
this.cache.Add(
url,
result,
DateTime.Now.AddMinutes(5));
return result;
}
}
}
示例4: DownloadName
public static NameResult DownloadName(int id)
{
string site;
var helper = new HttpHelper(@"http://myanimelist.net/showclubs.php?id=" + id);
helper.HttpWebRequest.AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate;
helper.HttpWebRequest.Proxy = null;
helper.HttpWebRequest.ServicePoint.ConnectionLimit = Int32.MaxValue;
using (var stream = helper.OpenRead())
{
using (var reader = new StreamReader(stream))
{
return NameFromClublist(reader.ReadToEnd());
}
}
}