本文整理汇总了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;
}
示例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);
}
示例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();
}
}
示例4: DisposeOfWebResponse
private static void DisposeOfWebResponse(WebResponse response)
{
if (response == null) return;
response.Close();
response.Dispose();
}