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


C# Message.ToHttpResponseMessage方法代码示例

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


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

示例1: AfterReceiveReply

 public void AfterReceiveReply(ref Message reply, object
     correlationState)
 {
     reply = TraceHttpResponseMessage(reply.ToHttpResponseMessage());
 }
开发者ID:ogazitt,项目名称:product,代码行数:5,代码来源:MessageLoggingHelper.cs

示例2: BeforeSendReply

 public void BeforeSendReply(ref Message reply, object
     correlationState)
 {
     reply = TraceHttpResponseMessage(reply.ToHttpResponseMessage());
 }
开发者ID:ogazitt,项目名称:product,代码行数:5,代码来源:MessageLoggingHelper.cs

示例3: ConfigureResponseMessage

        private void ConfigureResponseMessage(Message message)
        {
            Contract.Assert(message != null);

            HttpResponseMessageProperty responseProperty = new HttpResponseMessageProperty();
            HttpResponseMessage httpResponseMessage = message.ToHttpResponseMessage();

            if (httpResponseMessage == null)
            {
                responseProperty.StatusCode = HttpStatusCode.InternalServerError;
                responseProperty.SuppressEntityBody = true;
            }
            else
            {
                responseProperty.StatusCode = httpResponseMessage.StatusCode;
                if (httpResponseMessage.ReasonPhrase != null &&
                    httpResponseMessage.ReasonPhrase != DefaultReasonPhrase)
                {
                    responseProperty.StatusDescription = httpResponseMessage.ReasonPhrase;
                }

                CopyHeadersToNameValueCollection(httpResponseMessage.Headers, responseProperty.Headers);
                HttpContent content = httpResponseMessage.Content;
                if (content != null)
                {
                    CopyHeadersToNameValueCollection(httpResponseMessage.Content.Headers, responseProperty.Headers);
                }
                else
                {
                    responseProperty.SuppressEntityBody = true;
                }
            }

            message.Properties.Clear();
            message.Headers.Clear();

            message.Properties.Add(HttpResponseMessageProperty.Name, responseProperty);

            // The current request context flows with the Message for later use
            // by HttpMessageEncoder.WriteMessage
            message.Properties.Add(HttpMessageEncodingRequestContextPropertyName, this);
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:42,代码来源:HttpMessageEncodingRequestContext.cs

示例4: InvalidOperationException

        /// <summary>
        /// Called after the operation has returned but before the reply message is sent.
        /// </summary>
        /// <param name="reply">The reply message. This value is null if the operation is one way.</param>
        /// <param name="correlationState">The correlation object returned from the <see cref="AfterReceiveRequest(ref Message, IClientChannel, InstanceContext)"/> method.</param>
        void IDispatchMessageInspector.BeforeSendReply(
            ref Message reply,
            object correlationState)
        {
            if (reply == null)
            {
                throw Fx.Exception.ArgumentNull("reply");
            }

            HttpResponseMessage httpResponse = reply.ToHttpResponseMessage();

            if (httpResponse == null)
            {
                throw Fx.Exception.AsError(
                    new InvalidOperationException(
                        SR.HttpMessageInspectorNullMessage(this.GetType().Name, typeof(HttpResponseMessage).Name, "BeforeSendReply")));
            }

            this.BeforeSendReply(httpResponse, correlationState);
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:25,代码来源:HttpMessageInspector.cs

示例5: ConfigureResponseMessage

        private static Message ConfigureResponseMessage(Message message)
        {
            if (message == null)
            {
                return null;
            }

            HttpResponseMessageProperty responseProperty = new HttpResponseMessageProperty();

            HttpResponseMessage httpResponseMessage = message.ToHttpResponseMessage();
            if (httpResponseMessage == null)
            {
                responseProperty.StatusCode = HttpStatusCode.InternalServerError;
                responseProperty.SuppressEntityBody = true;
            }
            else
            {
                responseProperty.StatusCode = httpResponseMessage.StatusCode;
                if (httpResponseMessage.ReasonPhrase != null &&
                    httpResponseMessage.ReasonPhrase != DefaultReasonPhrase)
                {
                    responseProperty.StatusDescription = httpResponseMessage.ReasonPhrase;
                }

                CopyHeadersToNameValueCollection(httpResponseMessage.Headers, responseProperty.Headers);
                HttpContent content = httpResponseMessage.Content;
                if (content != null)
                {
                    ObjectContent objectContent = content as ObjectContent;
                    if (objectContent != null)
                    {
                        objectContent.DetermineWriteSerializerAndContentType();
                    }

                    CopyHeadersToNameValueCollection(httpResponseMessage.Content.Headers, responseProperty.Headers);
                }
                else
                {
                    responseProperty.SuppressEntityBody = true;
                }
            }

            message.Properties.Clear();
            message.Headers.Clear();

            message.Properties.Add(HttpResponseMessageProperty.Name, responseProperty);

            return message;
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:49,代码来源:HttpMessageEncodingRequestContext.cs

示例6: GetHttpResponseMessageOrThrow

            private static HttpResponseMessage GetHttpResponseMessageOrThrow(Message message)
            {
                HttpResponseMessage response = message.ToHttpResponseMessage();
                if (response == null)
                {
                    throw Error.InvalidOperation(
                        SRResources.MessageInvalidForHttpMessageEncoder,
                        _httpBindingClassName,
                        HttpMessageExtensions.ToMessageMethodName,
                        _httpResponseMessageClassName);
                }

                return response;
            }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:14,代码来源:HttpMessageEncoderFactory.cs

示例7: GetHttpResponseMessageOrThrow

            private static HttpResponseMessage GetHttpResponseMessageOrThrow(Message message)
            {
                HttpResponseMessage response = message.ToHttpResponseMessage();
                if (response == null)
                {
                    throw Fx.Exception.AsError(
                        new InvalidOperationException(
                            SR.MessageInvalidForHttpMessageEncoder(
                                httpBindingClassName,
                                HttpMessageExtensionMethods.ToMessageMethodName,
                                httpResponseMessageClassName)));
                }

                return response;
            }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:15,代码来源:HttpMessageEncoderFactory.cs


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