PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/WCFWebApi/src/Microsoft.Net.Http.Formatting/System/Net/Http/Formatting/MediaTypeConstants.cs

#
C# | 106 lines | 56 code | 8 blank | 42 comment | 0 complexity | f21a29eb9ed2780fd2fe089f0ed4d5eb MD5 | raw file
  1// <copyright>
  2//   Copyright (c) Microsoft Corporation.  All rights reserved.
  3// </copyright>
  4
  5namespace System.Net.Http.Formatting
  6{
  7    using System.Net.Http.Headers;
  8    using System.Text;
  9
 10    /// <summary>
 11    /// Constants related to media types.
 12    /// </summary>
 13    internal static class MediaTypeConstants
 14    {
 15        private static readonly MediaTypeHeaderValue DefaultApplicationXmlMediaType = new MediaTypeHeaderValue("application/xml");
 16        private static readonly MediaTypeHeaderValue DefaultTextXmlMediaType = new MediaTypeHeaderValue("text/xml");
 17        private static readonly MediaTypeHeaderValue DefaultApplicationJsonMediaType = new MediaTypeHeaderValue("application/json");
 18        private static readonly MediaTypeHeaderValue DefaultTextJsonMediaType = new MediaTypeHeaderValue("text/json");
 19        private static readonly MediaTypeHeaderValue DefaultTextHtmlMediaType = new MediaTypeHeaderValue("text/html") { CharSet = Encoding.UTF8.WebName };
 20        private static readonly MediaTypeHeaderValue DefaultApplicationFormUrlEncodedMediaType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
 21
 22        /// <summary>
 23        /// Gets a <see cref="MediaTypeHeaderValue"/> instance representing <c>text/html</c>.
 24        /// </summary>
 25        /// <value>
 26        /// A new <see cref="MediaTypeHeaderValue"/> instance representing <c>text/html</c>.
 27        /// </value>
 28        public static MediaTypeHeaderValue HtmlMediaType
 29        {
 30            get
 31            {
 32                return (MediaTypeHeaderValue)((ICloneable)DefaultTextHtmlMediaType).Clone();
 33            }
 34        }
 35
 36        /// <summary>
 37        /// Gets a <see cref="MediaTypeHeaderValue"/> instance representing <c>application/xml</c>.
 38        /// </summary>
 39        /// <value>
 40        /// A new <see cref="MediaTypeHeaderValue"/> instance representing <c>application/xml</c>.
 41        /// </value>
 42        public static MediaTypeHeaderValue ApplicationXmlMediaType
 43        {
 44            get
 45            {
 46                return (MediaTypeHeaderValue)((ICloneable)DefaultApplicationXmlMediaType).Clone();
 47            }
 48        }
 49
 50        /// <summary>
 51        /// Gets a <see cref="MediaTypeHeaderValue"/> instance representing <c>application/json</c>.
 52        /// </summary>
 53        /// <value>
 54        /// A new <see cref="MediaTypeHeaderValue"/> instance representing <c>application/json</c>.
 55        /// </value>
 56        public static MediaTypeHeaderValue ApplicationJsonMediaType
 57        {
 58            get
 59            {
 60                return (MediaTypeHeaderValue)((ICloneable)DefaultApplicationJsonMediaType).Clone();
 61            }
 62        }
 63
 64        /// <summary>
 65        /// Gets a <see cref="MediaTypeHeaderValue"/> instance representing <c>text/xml</c>.
 66        /// </summary>
 67        /// <value>
 68        /// A new <see cref="MediaTypeHeaderValue"/> instance representing <c>text/xml</c>.
 69        /// </value>
 70        public static MediaTypeHeaderValue TextXmlMediaType
 71        {
 72            get
 73            {
 74                return (MediaTypeHeaderValue)((ICloneable)DefaultTextXmlMediaType).Clone();
 75            }
 76        }
 77
 78        /// <summary>
 79        /// Gets a <see cref="MediaTypeHeaderValue"/> instance representing <c>text/json</c>.
 80        /// </summary>
 81        /// <value>
 82        /// A new <see cref="MediaTypeHeaderValue"/> instance representing <c>text/json</c>.
 83        /// </value>
 84        public static MediaTypeHeaderValue TextJsonMediaType
 85        {
 86            get
 87            {
 88                return (MediaTypeHeaderValue)((ICloneable)DefaultTextJsonMediaType).Clone();
 89            }
 90        }
 91
 92        /// <summary>
 93        /// Gets a <see cref="MediaTypeHeaderValue"/> instance representing <c>application/x-www-form-urlencoded</c>.
 94        /// </summary>
 95        /// <value>
 96        /// A new <see cref="MediaTypeHeaderValue"/> instance representing <c>application/x-www-form-urlencoded</c>.
 97        /// </value>
 98        public static MediaTypeHeaderValue ApplicationFormUrlEncodedMediaType
 99        {
100            get
101            {
102                return (MediaTypeHeaderValue)((ICloneable)DefaultApplicationFormUrlEncodedMediaType).Clone();
103            }
104        }
105    }
106}