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


C# HttpResponseMessage.ToMessage方法代码示例

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


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

示例1: TraceHttpResponseMessage

        private Message TraceHttpResponseMessage(HttpResponseMessage msg)
        {
            string tracemsg = String.Format(
                "Web Response Header: {0}\n" +
                "Web Response Body: {1}",
                msg,
                msg.Content != null ? msg.Content.ReadAsString() : "(empty)");

            LoggingHelper.TraceLine(tracemsg, LoggingHelper.LogLevel.Info);

            return msg.ToMessage();
        }
开发者ID:ogazitt,项目名称:TaskStore,代码行数:12,代码来源:MessageLoggingHelper.cs

示例2: TraceHttpResponseMessage

 private Message TraceHttpResponseMessage(HttpResponseMessage msg)
 {
     // response tracing is done in BaseResource.ReturnResult
     return msg.ToMessage();
 }
开发者ID:ogazitt,项目名称:product,代码行数:5,代码来源:MessageLoggingHelper.cs

示例3: CreateMessage

 public Message CreateMessage(HttpResponseMessage httpResponse)
 {
     var response = httpResponse.ToMessage();
     Assert.IsNotNull(response);
     return response;
 }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:6,代码来源:TestServiceBase.cs

示例4: ToMessage_Returns_HttpMessage_With_IsRequest_False

 public void ToMessage_Returns_HttpMessage_With_IsRequest_False()
 {
     HttpResponseMessage response = new HttpResponseMessage();
     HttpMessage message = response.ToMessage() as HttpMessage;
     Assert.IsFalse(message.IsRequest, "HttpResponseMessage.ToMessage should have returned an HttpMessage instance in which IsRequest is 'false'.");
 }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:6,代码来源:HttpMessageExtensionMethodsTests.cs

示例5: ToMessage_Returns_HttpMessage_For_HttpResponseMessage

 public void ToMessage_Returns_HttpMessage_For_HttpResponseMessage()
 {
     HttpResponseMessage request = new HttpResponseMessage();
     Message message = request.ToMessage();
     Assert.IsNotNull(message, "HttpResponseMessage.ToMessage should never return null.");
     Assert.IsInstanceOfType(message, typeof(HttpMessage), "HttpRequestMessage.ToMessage should have returned an HttpMessage instance.");
 }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:7,代码来源:HttpMessageExtensionMethodsTests.cs

示例6: ToHttpResponseMessage_Throws_If_Message_Is_Closed

        public void ToHttpResponseMessage_Throws_If_Message_Is_Closed()
        {
            HttpResponseMessage response = new HttpResponseMessage();
            Message wcfResponse = response.ToMessage();
            wcfResponse.Close();

            ExceptionAssert.Throws<ObjectDisposedException>(
                SR.MessageClosed,
                () =>
                {
                    wcfResponse.ToHttpResponseMessage();
                });
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:13,代码来源:HttpMessageExtensionMethodsTests.cs

示例7: ToHttpResponseMessage_Returns_The_Original_HttpResponseMessage

 public void ToHttpResponseMessage_Returns_The_Original_HttpResponseMessage()
 {
     HttpResponseMessage response = new HttpResponseMessage();
     Message wcfResponse = response.ToMessage();
     HttpResponseMessage responseRoundTripped = wcfResponse.ToHttpResponseMessage();
     Assert.IsNotNull(responseRoundTripped, "Message.ToHttpResponseMessage should not have returned null.");
     Assert.AreSame(response, responseRoundTripped, "Message.ToHttpResponseMessage should have returned the orignal instance of HttpResponseMessage.");
 }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:8,代码来源:HttpMessageExtensionMethodsTests.cs

示例8: ToHttpResponseMessage_Does_Not_Change_Message_State

 public void ToHttpResponseMessage_Does_Not_Change_Message_State()
 {
     HttpResponseMessage response = new HttpResponseMessage();
     Message wcfResponse = response.ToMessage();
     MessageState state = wcfResponse.State;
     wcfResponse.ToHttpResponseMessage();
     Assert.AreEqual(state, wcfResponse.State, "Message.State should be the same before and after calling Message.ToHttpResponseMessage.");
     HttpResponseMessage responseRoundTripped = wcfResponse.ToHttpResponseMessage();
 }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:9,代码来源:HttpMessageExtensionMethodsTests.cs

示例9: ToHttpResponseMessage_Can_Be_Called_Multiple_Times

        public void ToHttpResponseMessage_Can_Be_Called_Multiple_Times()
        {
            HttpResponseMessage response = new HttpResponseMessage();
            Message wcfResponse = response.ToMessage();
            HttpResponseMessage responseRoundTripped = wcfResponse.ToHttpResponseMessage();
            Assert.IsNotNull(responseRoundTripped, "Message.ToHttpResponseMessage should not have returned null.");
            Assert.AreSame(response, responseRoundTripped, "Message.ToHttpResponseMessage should have returned the orignal instance of HttpResponseMessage.");

            HttpResponseMessage responseRoundTrippedAgain = wcfResponse.ToHttpResponseMessage();
            Assert.IsNotNull(responseRoundTrippedAgain, "Message.ToHttpResponseMessage should not have returned null.");
            Assert.AreSame(response, responseRoundTrippedAgain, "Message.ToHttpResponseMessage should have returned the orignal instance of HttpResponseMessage.");
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:12,代码来源:HttpMessageExtensionMethodsTests.cs

示例10: ToHttpRequestMessage_Returns_Null_For_HttpResponseMessage

 public void ToHttpRequestMessage_Returns_Null_For_HttpResponseMessage()
 {
     HttpResponseMessage response = new HttpResponseMessage();
     Message wcfResponse = response.ToMessage();
     Assert.IsNull(wcfResponse.ToHttpRequestMessage(), "Message.ToHttpRequestMessage should have returned null.");
 }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:6,代码来源:HttpMessageExtensionMethodsTests.cs

示例11: BeforeSendReply_Receives_HttpResponseMessage

        public void BeforeSendReply_Receives_HttpResponseMessage()
        {
            HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
            Message wcfMessage = httpResponseMessage.ToMessage();

            IDispatchMessageInspector inspector = new MockHttpMessageInspector()
            {
                OnBeforeSendReply = (actualMessage, state) =>
                {
                    Assert.AreSame(httpResponseMessage, actualMessage, "BeforeSendReply did not receive the message we provided.");
                }
            };

            inspector.BeforeSendReply(ref wcfMessage, correlationState: null);
            Assert.AreSame(httpResponseMessage, wcfMessage.ToHttpResponseMessage(), "Expected embedded HttpResponseMessage to remain unmodified");
            Assert.IsTrue(((MockHttpMessageInspector)inspector).WasBeforeSendReplyCalled, "BeforeSentReply in derived class was not called");
        }
开发者ID:AlexZeitler,项目名称:WcfHttpMvcFormsAuth,代码行数:17,代码来源:HttpMessageInspectorTests.cs

示例12: BeforeSendReply_Receives_Custom_CorrelationState

        public void BeforeSendReply_Receives_Custom_CorrelationState()
        {
            HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
            Message wcfMessage = httpResponseMessage.ToMessage();
            object correlationState = "Hello";

            IDispatchMessageInspector inspector = new MockHttpMessageInspector()
            {
                OnBeforeSendReply = (actualMessage, state) =>
                {
                    Assert.AreSame(correlationState, state, "BeforeSendReply did not receive the state we provided.");
                }
            };

            inspector.BeforeSendReply(ref wcfMessage, correlationState);
            Assert.IsTrue(((MockHttpMessageInspector)inspector).WasBeforeSendReplyCalled, "BeforeSentReply in derived class was not called");
        }
开发者ID:AlexZeitler,项目名称:WcfHttpMvcFormsAuth,代码行数:17,代码来源:HttpMessageInspectorTests.cs

示例13: ToHttpResponseMessage_Throws_If_Message_Is_Closed

        public void ToHttpResponseMessage_Throws_If_Message_Is_Closed()
        {
            HttpResponseMessage response = new HttpResponseMessage();
            Message wcfResponse = response.ToMessage();
            wcfResponse.Close();

            ExceptionAssert.Throws(
                typeof(ObjectDisposedException),
                "Message.ToHttpResponseMessage should have thrown because the message is closed.",
                () =>
                {
                    wcfResponse.ToHttpResponseMessage();
                });
        }
开发者ID:AlexZeitler,项目名称:WcfHttpMvcFormsAuth,代码行数:14,代码来源:HttpMessageExtensionMethodsTests.cs

示例14: SendResponse

        private void SendResponse(RequestContext context)
        {
            Assert.IsNotNull(context);

            // Validate request
            var request = context.RequestMessage;
            Assert.IsNotNull(request);
            var httpRequest = request.ToHttpRequestMessage();
            Assert.IsNotNull(httpRequest);

            // Create response
            var httpResponse = new HttpResponseMessage(HttpStatusCode.OK, BasicChannelTests.ChannelHttpReasonPhrase);
            Assert.IsNotNull(httpResponse);
            TestServiceCommon.CopyTestHeader(httpRequest, httpResponse);

            // Send response
            var response = httpResponse.ToMessage();
            Assert.IsNotNull(response);
            context.Reply(response);
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:20,代码来源:ChannelTests.cs


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