本文整理汇总了C#中HttpBaseProtocolFilter.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# HttpBaseProtocolFilter.Dispose方法的具体用法?C# HttpBaseProtocolFilter.Dispose怎么用?C# HttpBaseProtocolFilter.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpBaseProtocolFilter
的用法示例。
在下文中一共展示了HttpBaseProtocolFilter.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostWebServiceDataAsync
private async Task PostWebServiceDataAsync(string mediaId)
{
try
{
Random random = new Random();
int r = random.Next();
string requestUrl = "http://replatform.cloudapp.net:8000/userAction?uuid={0}&type={1}&media_id={2}&from={3}&to={4}&r={5}";
string userid = App.gDeviceName;
requestUrl = String.Format(requestUrl, userid, App.gDeviceType, mediaId, App.NavigationRoadmap.GetFrom(), App.NavigationRoadmap.GetTo(), r);
HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
filter.AutomaticDecompression = true;
HttpClient httpClient = new HttpClient(filter);
CancellationTokenSource cts = new CancellationTokenSource();
filter.CacheControl.ReadBehavior = HttpCacheReadBehavior.Default;
filter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.Default;
Uri resourceUri;
if (!Uri.TryCreate(requestUrl.Trim(), UriKind.Absolute, out resourceUri))
{
return;
}
HttpResponseMessage response = await httpClient.GetAsync(resourceUri).AsTask(cts.Token);
string jsonText = await Helpers.GetResultAsync(response, cts.Token);
GetPostUserActionResult(jsonText);
if (filter != null)
{
filter.Dispose();
filter = null;
}
if (httpClient != null)
{
httpClient.Dispose();
httpClient = null;
}
if (cts != null)
{
cts.Dispose();
cts = null;
}
}
catch (Exception) { }
}
示例2: GetWebServiceRelatedDataAsync
private async Task GetWebServiceRelatedDataAsync(ReDataGroup group)
{
try
{
if ((group == null) && (group.UniqueId.Equals(string.Empty)))
{
return;
}
string requestUrl = "http://replatform.cloudapp.net:8000/getrelated/?id={0}&uuid={1}&type={2}&from={3}&to={4}";
//string requestUrl = "http://192.168.1.215:9999/getrelated/?id={0}";
requestUrl = String.Format(requestUrl, group.UniqueId, App.gDeviceName, App.gDeviceType, App.NavigationRoadmap.GetFrom(), App.NavigationRoadmap.GetTo());
HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
filter.AutomaticDecompression = true;
HttpClient httpClient = new HttpClient(filter);
CancellationTokenSource cts = new CancellationTokenSource();
filter.CacheControl.ReadBehavior = HttpCacheReadBehavior.Default;
filter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.Default;
Uri resourceUri;
if (!Uri.TryCreate(requestUrl.Trim(), UriKind.Absolute, out resourceUri))
{
return;
}
HttpResponseMessage response = await httpClient.GetAsync(resourceUri).AsTask(cts.Token);
string jsonText = await Helpers.GetResultAsync(response, cts.Token);
if (filter != null)
{
filter.Dispose();
filter = null;
}
if (httpClient != null)
{
httpClient.Dispose();
httpClient = null;
}
if (cts != null)
{
cts.Dispose();
cts = null;
}
GetRelatedResultJsonData(group, jsonText);
}
catch (Exception e)
{
String ex = e.Message;
}
}
示例3: GetWebServiceSearchDataAsync
//public static async Task<ReDataItem> GetItemAsync(string uniqueId)
//{
// //await _reDataSource.GetReDataAsync();
// await _reSearchDataSource.GetWebServiceDataAsync();
// // Simple linear search is acceptable for small data sets
// var matches = _reSearchDataSource.Groups.SelectMany(group => group.Items).Where((item) => item.UniqueId.Equals(uniqueId));
// if (matches.Count() == 1) return matches.First();
// return null;
//}
//private async Task GetReDataAsync()
//{
// if (this._groups.Count != 0)
// return;
// Uri dataUri = new Uri("ms-appx:///DataModel/ReData.json");
// StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);
// string jsonText = await FileIO.ReadTextAsync(file);
// JsonObject jsonObject = JsonObject.Parse(jsonText);
// JsonArray jsonArray = jsonObject["Groups"].GetArray();
// foreach (JsonValue groupValue in jsonArray)
// {
// JsonObject groupObject = groupValue.GetObject();
// ReDataGroup group = new ReDataGroup(groupObject["UniqueId"].GetString(),
// groupObject["Title"].GetString());
// int index = 0;
// foreach (JsonValue itemValue in groupObject["Items"].GetArray())
// {
// JsonObject itemObject = itemValue.GetObject();
// string uniqueIdTmp = itemObject["UniqueId"].GetString();
// string titleTmp = itemObject["Title"].GetString();
// string subTitleTmp = itemObject["Subtitle"].GetString();
// string imagePathTmp = itemObject["ImagePath"].GetString();
// string descriptionTmp = itemObject["Description"].GetString();
// string playUrlTmp = itemObject["PlayUrl"].GetString();
// ReDataItem ri = new ReDataItem(index, uniqueIdTmp);
// group.Items.Add(ri);
// index++;
// }
// this.Groups.Add(group);
// }
//}
private async Task GetWebServiceSearchDataAsync(string key)
{
try
{
key = System.Net.WebUtility.UrlEncode(key);
string requstUrl = "http://replatform.cloudapp.net:8000/getsearch?v={0}&uuid={1}&type={2}&from={3}&to={4}";
requstUrl = String.Format(requstUrl, key, App.gDeviceName, App.gDeviceType, App.NavigationRoadmap.GetFrom(), App.NavigationRoadmap.GetTo());
HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
filter.AutomaticDecompression = true;
HttpClient httpClient = new HttpClient(filter);
CancellationTokenSource cts = new CancellationTokenSource();
filter.CacheControl.ReadBehavior = HttpCacheReadBehavior.Default;
filter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.Default;
Uri resourceUri;
if (!Uri.TryCreate(requstUrl.Trim(), UriKind.Absolute, out resourceUri))
{
return;
}
HttpResponseMessage response = await httpClient.GetAsync(resourceUri).AsTask(cts.Token);
string jsonText = await Helpers.GetResultAsync(response, cts.Token);
GetSearchResultJsonData(jsonText);
if (filter != null)
{
filter.Dispose();
filter = null;
}
if (httpClient != null)
{
httpClient.Dispose();
httpClient = null;
}
if (cts != null)
{
cts.Dispose();
cts = null;
}
}
catch(Exception) {}
}
示例4: GetWebServiceDataAsync
private async Task GetWebServiceDataAsync()
{
try
{
string requestUrl = "http://replatform.cloudapp.net:8000/getguess/?uuid={0}&type={1}&page={2}&from={3}&to={4}&r={5}";
//string requestUrl = "http://192.168.1.215:9999/getguess/?uuid={0}&page={1}";
string userid = App.gDeviceName;
string type = App.gDeviceType;
Random random = new Random();
int page = defaultPageValue;//random.Next(iMinInclusivePageValue, iMaxExclusivePageValue);
int r = random.Next();
requestUrl = String.Format(requestUrl, userid, type, page, App.NavigationRoadmap.GetFrom(), App.NavigationRoadmap.GetTo(), r);
HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
filter.AutomaticDecompression = true;
HttpClient httpClient = new HttpClient(filter);
CancellationTokenSource cts = new CancellationTokenSource();
filter.CacheControl.ReadBehavior = HttpCacheReadBehavior.Default;
filter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.Default;
Uri resourceUri;
if (!Uri.TryCreate(requestUrl.Trim(), UriKind.Absolute, out resourceUri))
{
return;
}
HttpResponseMessage response = await httpClient.GetAsync(resourceUri).AsTask(cts.Token);
string jsonText = await Helpers.GetResultAsync(response, cts.Token);
GetResultJsonData(jsonText);
if (filter != null)
{
filter.Dispose();
filter = null;
}
if (httpClient != null)
{
httpClient.Dispose();
httpClient = null;
}
if (cts != null)
{
cts.Dispose();
cts = null;
}
}
catch(Exception) {}
}