当前位置: 首页>>代码示例>>C#>>正文


C# HttpBaseProtocolFilter.Dispose方法代码示例

本文整理汇总了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) { }
        }
开发者ID:RaulVan,项目名称:Recommender,代码行数:49,代码来源:ReUserActionDataSource.cs

示例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;
            }
        }
开发者ID:RaulVan,项目名称:Recommender,代码行数:55,代码来源:ReDetailDataSource.cs

示例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) {}
        }
开发者ID:RaulVan,项目名称:Recommender,代码行数:94,代码来源:ReSearchDataSource.cs

示例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) {}
        }
开发者ID:RaulVan,项目名称:Recommender,代码行数:52,代码来源:ReDataSource.cs


注:本文中的HttpBaseProtocolFilter.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。