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


C# WebResponse.Dispose方法代码示例

本文整理汇总了C#中System.Net.WebResponse.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# WebResponse.Dispose方法的具体用法?C# WebResponse.Dispose怎么用?C# WebResponse.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.WebResponse的用法示例。


在下文中一共展示了WebResponse.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetLegendResponseFromWebresponse

        private static ArcGISLegendResponse GetLegendResponseFromWebresponse(WebResponse webResponse)
        {
            var dataStream = webResponse.GetResponseStream();

            if (dataStream != null)
            {
                var sReader = new StreamReader(dataStream);
                var jsonString = sReader.ReadToEnd();

                var serializer = new JsonSerializer();
                var jToken = JObject.Parse(jsonString);
                var legendResponse = (ArcGISLegendResponse)serializer.Deserialize(new JTokenReader(jToken), typeof(ArcGISLegendResponse));

                dataStream.Dispose();
                webResponse.Dispose();

                return legendResponse;
            }

            webResponse.Dispose();

            return null;
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:23,代码来源:ArcGISLegend.cs

示例2: OnWebResponseReceived

        /// <summary>
        /// Process the web response from the server.
        /// </summary>
        protected override void OnWebResponseReceived(WebResponse response)
        {
            LiveLoginResult result;

            bool nullResponse = (response == null);
            try
            {
                Stream responseStream = (!nullResponse) ? response.GetResponseStream() : null;
                if (nullResponse || responseStream == null)
                {
                    result = new LiveLoginResult(
                        new LiveAuthException(AuthErrorCodes.ClientError, ResourceHelper.GetString("ConnectionError")));
                }
                else
                {
                    result = this.GenerateLoginResultFrom(responseStream);
                }
            }
            finally
            {
                if (!nullResponse)
                {
                    response.Dispose();
                }
            }

            this.OnOperationCompleted(result);
        }
开发者ID:namy14,项目名称:LiveSDK-for-Windows,代码行数:31,代码来源:RefreshTokenOperation.cs

示例3: parseXMLtoMap

        private Map parseXMLtoMap(WebResponse xmlResponse)
        {
            try
            {
                using (var contentStream = xmlResponse.GetResponseStream())
                {
                    XDocument load = XDocument.Load(contentStream);
                    var data = from query in load.Descendants("ImageOptions")
                               select new Map
                               {
                                   Name = (string)query.Element("Name"),
                                   Description = (string)query.Element("Description"),
                                   NWLat = (double)query.Element("NWLat"),
                                   NWLong = (double)query.Element("NWLong"),
                                   SELat = (double)query.Element("SELat"),
                                   SELong = (double)query.Element("SELong"),
                                   SWLat = (double)query.Element("SWLat"),
                                   SWLong = (double)query.Element("SWLong"),
                                   NELat = (double)query.Element("NELat"),
                                   NELong = (double)query.Element("NELong"),
                                   ZoomLevel = (int?)query.Element("ZommLevel"),
                                   Transparency = (int?)query.Element("Transparency")
                               };
                    if (data.Count() > 1)
                        this.Log().Debug("Multiple Map XML Elements in content stream");

                    return data.FirstOrDefault();
                }
            }
            finally
            {
                xmlResponse.Dispose();
            }
        }
开发者ID:SNSB,项目名称:DiversityMobile,代码行数:34,代码来源:MapTransferService.cs

示例4: DisposeOfWebResponse

 private static void DisposeOfWebResponse(WebResponse response)
 {
     if (response == null) return;
       response.Close();
       response.Dispose();
 }
开发者ID:jegglestone,项目名称:Animal-Store,代码行数:6,代码来源:SearchAPIFacade.cs


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