Пример #1
0
 protected override sealed double OnTryMatchMediaType(HttpResponseMessage response)
 {
     if (!string.Equals(GetUriPathExtensionOrNull(response.RequestMessage.RequestUri), this.UriPathExtension, StringComparison.Ordinal))
     {
         return 0.0;
     }
     return 1.0;
 }
Пример #2
0
 protected override sealed double OnTryMatchMediaType(HttpResponseMessage response)
 {
     NameValueCollection queryString = response.RequestMessage.QueryString;
     if (!this.DoesQueryStringMatch(queryString))
     {
         return 0.0;
     }
     return 1.0;
 }
Пример #3
0
 protected override double OnTryMatchMediaType(HttpResponseMessage response)
 {
     if (response == null)
     {
         throw new ArgumentNullException("response");
     }
     if (response.RequestMessage != null)
     {
         return this.OnTryMatchMediaType(response.RequestMessage);
     }
     return 0.0;
 }
Пример #4
0
 public double TryMatchMediaType(HttpResponseMessage response)
 {
     if (response == null)
     {
         throw new ArgumentNullException("response");
     }
     if (response.RequestMessage == null)
     {
         throw new InvalidOperationException(String.Format(SRResources.ResponseMustReferenceRequest, httpResponseMessageType.Name, "response", httpRequestMessageType.Name, "RequestMessage"));
     }
     return this.OnTryMatchMediaType(response);
 }
Пример #5
0
 protected override double OnTryMatchMediaType(HttpResponseMessage response)
 {
     if (response == null)
     {
         throw new ArgumentNullException("response");
     }
     if (response.RequestMessage != null)
     {
         return MatchHeaderValue(response.RequestMessage, this.HeaderName, this.HeaderValue, this.HeaderValueComparison, this.IsValueSubstring);
     }
     return 0.0;
 }
Пример #6
0
 protected override sealed double OnTryMatchMediaType(HttpResponseMessage response)
 {
     IEnumerable<MediaTypeWithQualityHeaderValue> accept = response.RequestMessage.AcceptHeaders;
     if (accept != null)
     {
         foreach (MediaTypeWithQualityHeaderValue value2 in accept)
         {
             if ((value2 != null) && MediaTypeHeaderValueEqualityComparer.EqualityComparer.Equals(this.MediaRange, value2))
             {
                 return (value2.Quality.HasValue ? value2.Quality.Value : 1.0);
             }
         }
     }
     return 0.0;
 }
Пример #7
0
 protected virtual IEnumerable<KeyValuePair<string, string>> OnGetResponseHeaders(Type objectType, string mediaType, HttpResponseMessage responseMessage)
 {
     return null;
 }
Пример #8
0
 internal bool TryMatchMediaTypeMapping(HttpResponseMessage response, out MediaTypeFormatterMatch mediaTypeMatch)
 {
     foreach (MediaTypeMapping mapping in this.MediaTypeMappings)
     {
         double quality;
         if ((mapping != null) && ((quality = mapping.TryMatchMediaType(response)) > 0.0))
         {
             mediaTypeMatch = new MediaTypeFormatterMatch(mapping.MediaType, quality);
             return true;
         }
     }
     mediaTypeMatch = null;
     return false;
 }
Пример #9
0
 //internal bool CanWriteAs(Type type, FormatterContext formatterContext, out MediaTypeHeaderValue matchedMediaType)
 //{
 //    if (type == null)
 //    {
 //        throw new ArgumentNullException("type");
 //    }
 //    if (formatterContext == null)
 //    {
 //        throw new ArgumentNullException("formatterContext");
 //    }
 //    if (!this.CanWriteType(type))
 //    {
 //        matchedMediaType = null;
 //        return false;
 //    }
 //    MediaTypeFormatterMatch mediaTypeMatch = null;
 //    HttpRequestMessage request = formatterContext.Request;
 //    MediaTypeHeaderValue mediaType = request != null ? request.ContentType : formatterContext.ContentType;
 //    if ((mediaType != null) && this.TryMatchSupportedMediaType(mediaType, out mediaTypeMatch))
 //    {
 //        matchedMediaType = mediaTypeMatch.MediaType;
 //        return true;
 //    }
 //    if ((request != null) && this.TryMatchMediaTypeMapping(request, out mediaTypeMatch))
 //    {
 //        matchedMediaType = mediaTypeMatch.MediaType;
 //        return true;
 //    }
 //    matchedMediaType = null;
 //    return false;
 //}
 internal IEnumerable<KeyValuePair<string, string>> GetResponseHeaders(Type objectType, string mediaType, HttpResponseMessage responseMessage)
 {
     return this.OnGetResponseHeaders(objectType, mediaType, responseMessage);
 }
Пример #10
0
 protected abstract double OnTryMatchMediaType(HttpResponseMessage response);