예제 #1
0
        protected sealed override void setValue(object value)
        {
            var response = value as IRestResponse;

            if (Request != null)
            {
                Request.SetValue(response.Request);
            }

            if (ErrorMessage != null)
            {
                ErrorMessage.SetValue(response.ErrorMessage);
            }

            if (ResponseStatus != null)
            {
                ResponseStatus.SetValue(response.ResponseStatus);
            }

            if (Headers != null)
            {
                foreach (var header in Headers)
                {
                    var headerValue = response.Headers.FirstOrDefault(h => h.Name == header.Key);
                    if (headerValue != null)
                    {
                        header.Value.SetValue(headerValue.Value);
                    }
                }
            }

            if (Cookies != null)
            {
                foreach (var cookie in Cookies)
                {
                    var cookieValue = response.Cookies.FirstOrDefault(c => c.Name == cookie.Key);
                    if (cookieValue != null)
                    {
                        cookie.Value.SetValue(cookieValue.Value);
                    }
                }
            }

            if (Server != null)
            {
                Server.SetValue(response.Server);
            }

            if (ResponseUri != null)
            {
                ResponseUri.SetValue(response.ResponseUri);
            }

            if (ErrorException != null)
            {
                ErrorException.SetValue(response.ErrorException);
            }

            if (RawBytes != null)
            {
                RawBytes.SetValue(response.RawBytes);
            }

            if (IsSuccessful != null)
            {
                IsSuccessful.SetValue(response.IsSuccessful);
            }

            if (StatusCode != null)
            {
                StatusCode.SetValue(response.StatusCode);
            }

            if (Content != null)
            {
                Content.SetValue(response.Content);
            }

            if (ContentEncoding != null)
            {
                ContentEncoding.SetValue(response.ContentEncoding);
            }

            if (ContentLength != null)
            {
                ContentLength.SetValue(response.ContentLength);
            }

            if (ContentType != null)
            {
                ContentType.SetValue(response.ContentType);
            }

            if (StatusDescription != null)
            {
                StatusDescription.SetValue(response.StatusDescription);
            }

            if (ProtocolVersion != null)
            {
                ProtocolVersion.SetValue(response.ProtocolVersion);
            }

            setExtraValues(response);
        }