コード例 #1
0
        /// <summary>
        /// Creates a new CloudHttpRequestErrorInfo from a HttpRequestMessage.
        /// </summary>
        /// <param name="request">The request message.</param>
        /// <param name="content">
        /// The request content, which may be passed separately if the request
        /// has already been disposed.
        /// </param>
        /// <returns>A CloudHttpRequestErrorInfo instance.</returns>
        public static CloudHttpRequestErrorInfo Create(HttpRequestMessage request, string content)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            CloudHttpRequestErrorInfo info = new CloudHttpRequestErrorInfo();

            // Copy CloudHttpErrorInfo properties
            info.Content = content;
            info.Version = request.Version;
            info.CopyHeaders(request.Headers);
            info.CopyHeaders(request.GetContentHeaders());

            // Copy CloudHttpRequestErrorInfo properties
            info.Method = request.Method;
            info.RequestUri = request.RequestUri;
            if (request.Properties != null)
            {
                foreach (KeyValuePair<string, object> pair in request.Properties)
                {
                    info.Properties[pair.Key] = pair.Value;
                }
            }
            
            return info;
        }
コード例 #2
0
        /// <summary>
        /// Creates a new CloudHttpRequestErrorInfo from a HttpRequestMessage.
        /// </summary>
        /// <param name="request">The request message.</param>
        /// <param name="content">
        /// The request content, which may be passed separately if the request
        /// has already been disposed.
        /// </param>
        /// <returns>A CloudHttpRequestErrorInfo instance.</returns>
        public static CloudHttpRequestErrorInfo Create(HttpRequestMessage request, string content)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            CloudHttpRequestErrorInfo info = new CloudHttpRequestErrorInfo();

            // Copy CloudHttpErrorInfo properties
            info.Content = content;
            info.Version = request.Version;
            info.CopyHeaders(request.Headers);
            info.CopyHeaders(request.GetContentHeaders());

            // Copy CloudHttpRequestErrorInfo properties
            info.Method     = request.Method;
            info.RequestUri = request.RequestUri;
            if (request.Properties != null)
            {
                foreach (KeyValuePair <string, object> pair in request.Properties)
                {
                    info.Properties[pair.Key] = pair.Value;
                }
            }

            return(info);
        }