Beispiel #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="name">The friendly name of the format.</param>
        /// <param name="mediaTypeName">The correct media type name for content negotiation.</param>
        /// <param name="contractResolver">The resource contract resolver used to resolve the contracts at runtime.</param>
        protected HypermediaMediaTypeFormatter(string name, string mediaTypeName, IContractResolver contractResolver)
        {
            ContractResolver = contractResolver;

            SupportedMediaTypes.Clear();
            SupportedMediaTypes.Insert(0, new MediaTypeHeaderValue(mediaTypeName));

            MediaTypeMappings.Clear();
            MediaTypeMappings.Add(new QueryStringMapping("$format", name, mediaTypeName));
        }
        public JsonpMediaTypeFormatter()
        {
            // Do not want to inherit supported media types or
            // media type mappings of JSON
            SupportedMediaTypes.Clear();
            MediaTypeMappings.Clear();

            // We have our own!
            SupportedMediaTypes.Add(new MediaTypeHeaderValue(JAVASCRIPT_MIME));
            MediaTypeMappings.Add(new QueryStringMapping("frmt", "jsonp", JAVASCRIPT_MIME));
        }