/// <summary>
        /// Configure the media type tables so that Json Light is the first JSON format in the table.
        /// </summary>
        /// <remarks>
        /// This is only used in V4 and beyond.
        /// </remarks>
        private void AddJsonLightMediaTypes()
        {
            var optionalParameters = new[]
            {
                new
                {
                    ParameterName = MimeConstants.MimeMetadataParameterName,
                    Values        = new[] { MimeConstants.MimeMetadataParameterValueMinimal, MimeConstants.MimeMetadataParameterValueFull, MimeConstants.MimeMetadataParameterValueNone }
                },
                new
                {
                    ParameterName = MimeConstants.MimeStreamingParameterName,
                    Values        = new[] { MimeConstants.MimeParameterValueTrue, MimeConstants.MimeParameterValueFalse }
                },
                new
                {
                    ParameterName = MimeConstants.MimeIeee754CompatibleParameterName,
                    Values        = new[] { MimeConstants.MimeParameterValueFalse, MimeConstants.MimeParameterValueTrue }
                },
            };

            // initial seed for the list will be extended in breadth-first passes over the optional parameters
            var mediaTypesToAdd = new LinkedList <MediaType>();

            mediaTypesToAdd.AddFirst(ApplicationJsonMediaType);

            foreach (var optionalParameter in optionalParameters)
            {
                // go through each one so far and extend it
                for (LinkedListNode <MediaType> currentNode = mediaTypesToAdd.First; currentNode != null; currentNode = currentNode.Next)
                {
                    MediaType typeToExtend = currentNode.Value;
                    foreach (string valueToAdd in optionalParameter.Values)
                    {
                        var extendedParameters = new List <KeyValuePair <string, string> >(typeToExtend.Parameters ?? Enumerable.Empty <KeyValuePair <string, string> >())
                        {
                            new KeyValuePair <string, string>(optionalParameter.ParameterName, valueToAdd)
                        };

                        var extendedMediaType = new MediaType(typeToExtend.TypeName, typeToExtend.SubTypeName, extendedParameters);

                        // always match more specific things first
                        mediaTypesToAdd.AddBefore(currentNode, extendedMediaType);
                    }
                }
            }

            List <MediaTypeWithFormat> JsonMediaTypeWithFormatList = new List <MediaTypeWithFormat>();
            MediaTypeWithFormat        applicationJson             = null;

            foreach (MediaType mediaType in mediaTypesToAdd)
            {
                var mediaTypeWithFormat = new MediaTypeWithFormat {
                    Format = ODataFormat.Json, MediaType = mediaType
                };
                if (mediaType == ApplicationJsonMediaType)
                {
                    applicationJson = mediaTypeWithFormat;
                }
                else
                {
                    JsonMediaTypeWithFormatList.Insert(0, mediaTypeWithFormat);
                }
            }

            if (applicationJson != null)
            {
                JsonMediaTypeWithFormatList.Insert(0, applicationJson);
            }

            this.AddForJsonPayloadKinds(JsonMediaTypeWithFormatList);
        }
        /// <summary>
        /// Inserts the specified media type before the first occurrence of <paramref name="beforeFormat"/>.
        /// </summary>
        /// <param name="mediaTypeList">The media type list to insert into.</param>
        /// <param name="mediaTypeToInsert">The media type to insert.</param>
        /// <param name="beforeFormat">The format of the media type before which <paramref name="mediaTypeToInsert"/> should be inserted.</param>
        private static void AddMediaTypeEntryOrdered(IList <MediaTypeWithFormat> mediaTypeList, MediaTypeWithFormat mediaTypeToInsert, ODataFormat beforeFormat)
        {
            Debug.Assert(mediaTypeList != null, "mediaTypeList != null");
            Debug.Assert(mediaTypeToInsert != null, "mediaTypeToInsert != null");
            Debug.Assert(beforeFormat != null, "beforeFormat != null");

            // Go through the list and find the first entry that has the specified format to insert before.
            for (int i = 0; i < mediaTypeList.Count; ++i)
            {
                if (mediaTypeList[i].Format == beforeFormat)
                {
                    mediaTypeList.Insert(i, mediaTypeToInsert);
                    return;
                }
            }

            mediaTypeList.Add(mediaTypeToInsert);
        }