Esempio n. 1
0
 internal bool TryMatchMediaTypeMapping(HttpRequestMessage request, out MediaTypeFormatterMatch mediaTypeMatch)
 {
     foreach (MediaTypeMapping mapping in this.MediaTypeMappings)
     {
         double num;
         if ((mapping != null) && ((num = mapping.TryMatchMediaType(request)) > 0.0))
         {
             mediaTypeMatch = new MediaTypeFormatterMatch(mapping.MediaType, num);
             return true;
         }
     }
     mediaTypeMatch = null;
     return false;
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
        /// <summary>
        /// Evaluates whether a match is better than the current match and if so returns the replacement; otherwise returns the 
        /// current match.
        /// </summary>
        protected virtual MediaTypeFormatterMatch UpdateBestMatch(MediaTypeFormatterMatch current, MediaTypeFormatterMatch potentialReplacement)
        {
            if (potentialReplacement == null)
            {
                return current;
            }

            if (current != null)
            {
                return (potentialReplacement.Quality > current.Quality) ? potentialReplacement : current;
            }

            return potentialReplacement;
        }