本文整理汇总了C#中System.Net.Http.HttpResponseMessage.GetResponseStream方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseMessage.GetResponseStream方法的具体用法?C# HttpResponseMessage.GetResponseStream怎么用?C# HttpResponseMessage.GetResponseStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.HttpResponseMessage
的用法示例。
在下文中一共展示了HttpResponseMessage.GetResponseStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseReadResultResponse
private static LisResult ParseReadResultResponse(HttpResponseMessage webResponse)
{
if (webResponse == null)
{
return new LisResult { IsValid = false, Message = "Invalid webResponse" };
}
var stream = webResponse.GetResponseStream();
if (stream == null)
{
return new LisResult { IsValid = false, Message = "Invalid stream" };
}
var imsxEnvelope = (imsx_POXEnvelopeType)ImsxResponseSerializer.Deserialize(stream);
var imsxHeader = (imsx_ResponseHeaderInfoType) imsxEnvelope.imsx_POXHeader.Item;
var imsxStatus = imsxHeader.imsx_statusInfo.imsx_codeMajor;
if (imsxStatus != imsx_CodeMajorType.success)
{
return new LisResult { IsValid = false, Message = imsxHeader.imsx_statusInfo.imsx_description};
}
var imsxBody = (readResultResponse) imsxEnvelope.imsx_POXBody.Item;
if (imsxBody?.result == null)
{
return new LisResult { Score = null, IsValid = true };
}
double result;
if (double.TryParse(imsxBody.result.resultScore.textString, out result))
{
return new LisResult { Score = result, IsValid = true };
}
return new LisResult { Score = null, IsValid = true };
}
示例2: ParsePostResultResponse
private static BasicResult ParsePostResultResponse(HttpResponseMessage webResponse)
{
if (webResponse == null) return new BasicResult(false, "Invalid webResponse");
var stream = webResponse.GetResponseStream();
if (stream == null) return new BasicResult(false, "Invalid stream");
var imsxEnvelope = ImsxResponseSerializer.Deserialize(stream) as imsx_POXEnvelopeType;
if (imsxEnvelope == null) return new BasicResult(false, "Invalid imsxEnvelope");
var imsxHeader = imsxEnvelope.imsx_POXHeader.Item as imsx_ResponseHeaderInfoType;
if (imsxHeader == null) return new BasicResult(false, "Invalid imsxHeader");
var imsxStatus = imsxHeader.imsx_statusInfo.imsx_codeMajor;
return new BasicResult(imsxStatus == imsx_CodeMajorType.success,
imsxHeader.imsx_statusInfo.imsx_description);
}