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


C# HttpResponseMessage.GetResponseStream方法代码示例

本文整理汇总了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 };
        }
开发者ID:andyfmiller,项目名称:LtiLibrary,代码行数:36,代码来源:OutcomesClient.cs

示例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);
        }
开发者ID:andyfmiller,项目名称:LtiLibrary,代码行数:18,代码来源:OutcomesClient.cs


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