/// <summary>
        /// Initializes a new instance of the <see cref="JsonMediaTypeFormatter"/> class.
        /// </summary>
        public JsonMediaTypeFormatter()
        {
            // Set default supported media types
            this.SupportedMediaTypes.Add(MediaTypeConstants.ApplicationJsonMediaType);
            this.SupportedMediaTypes.Add(MediaTypeConstants.TextJsonMediaType);

#if !NETFX_CORE // MediaTypeMappings are not supported in portable library
            this._requestHeaderMapping = new XmlHttpRequestHeaderMapping();
            this.MediaTypeMappings.Add(this._requestHeaderMapping);
#endif
        }
        /// <summary>
        /// Updates the given <paramref name="formatter"/>'s set of <see cref="MediaTypeMapping"/> elements
        /// so that it associates the <paramref name="mediaType"/> with a specific HTTP request header field
        /// with a specific value.
        /// </summary>
        /// <remarks><see cref="RequestHeaderMapping"/> checks header fields associated with <see cref="M:HttpRequestMessage.Headers"/> for a match. It does
        /// not check header fields associated with <see cref="M:HttpResponseMessage.Headers"/> or <see cref="M:HttpContent.Headers"/> instances.</remarks>
        /// <param name="formatter">The <see cref="MediaTypeFormatter"/> to receive the new <see cref="MediaTypeMapping"/> item.</param>
        /// <param name="headerName">Name of the header to match.</param>
        /// <param name="headerValue">The header value to match.</param>
        /// <param name="valueComparison">The <see cref="StringComparison"/> to use when matching <paramref name="headerValue"/>.</param>
        /// <param name="isValueSubstring">if set to <c>true</c> then <paramref name="headerValue"/> is 
        /// considered a match if it matches a substring of the actual header value.</param>
        /// <param name="mediaType">The <see cref="MediaTypeHeaderValue"/> to associate 
        /// with a <see cref="M:HttpRequestMessage.Header"/> entry with a name matching <paramref name="headerName"/>
        /// and a value matching <paramref name="headerValue"/>.</param>
        public static void AddRequestHeaderMapping(
            this MediaTypeFormatter formatter,
            string headerName,
            string headerValue,
            StringComparison valueComparison,
            bool isValueSubstring,
            MediaTypeHeaderValue mediaType)
        {
            if (formatter == null)
            {
                throw Error.ArgumentNull("formatter");
            }

            RequestHeaderMapping mapping = new RequestHeaderMapping(headerName, headerValue, valueComparison, isValueSubstring, mediaType);
            formatter.MediaTypeMappings.Add(mapping);
        }