Beispiel #1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="mediaType">Media type with subtype. For example <b>text/plain</b>.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>mediaType</b> is null reference.</exception>
        public MIME_h_ContentType(string mediaType)
        {
            if (mediaType == null)
            {
                throw new ArgumentNullException(mediaType);
            }

            /*string[] type_subtype = mediaType.Split(new[] {'/',}, 2);
             * if (type_subtype.Length == 2)
             * {
             *  if (type_subtype[0] == "" || !MIME_Reader.IsToken(type_subtype[0]))
             *  {
             *      throw new ArgumentException("Invalid argument 'mediaType' value '" + mediaType +
             *                                  "', value must be token.");
             *  }
             *  if (type_subtype[1] == "" || !MIME_Reader.IsToken(type_subtype[1]))
             *  {
             *      throw new ArgumentException("Invalid argument 'mediaType' value '" + mediaType +
             *                                  "', value must be token.");
             *  }
             *
             *  m_Type = type_subtype[0];
             *  m_SubType = type_subtype[1];
             * }
             * else
             * {
             *  throw new ArgumentException("Invalid argument 'mediaType' value '" + mediaType + "'.");
             * }
             *
             * m_pParameters = new MIME_h_ParameterCollection(this);
             * m_IsModified = true;*/

            MIME_Reader r    = new MIME_Reader(mediaType);
            string      type = r.Token();

            if (type == null)
            {
                throw new ParseException("Invalid Content-Type: header field value '" + mediaType + "'.");
            }
            m_Type = type;

            if (r.Char(false) != '/')
            {
                throw new ParseException("Invalid Content-Type: header field value '" + mediaType + "'.");
            }

            string subtype = r.Token();

            if (subtype == null)
            {
                //throw new ParseException("Invalid Content-Type: header field value '" + value + "'.");
                subtype = "";
            }
            m_SubType     = subtype;
            m_pParameters = new MIME_h_ParameterCollection(this);
            m_pParameters.Parse(r);

            m_ParseValue = mediaType;
            m_IsModified = true;
        }
Beispiel #2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="dispositionType">The disposition-type. Known values are in <see cref="MIME_DispositionTypes">MIME_DispositionTypes</see>.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>dispositionType</b> is null reference.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        public MIME_h_ContentDisposition(string dispositionType)
        {
            if (dispositionType == null)
            {
                throw new ArgumentNullException("dispositionType");
            }
            if (dispositionType == string.Empty)
            {
                throw new ArgumentException("Argument 'dispositionType' value must be specified.");
            }

            m_DispositionType = dispositionType;

            m_pParameters = new MIME_h_ParameterCollection(this);
            m_IsModified  = true;
        }
Beispiel #3
0
 /// <summary>
 /// Internal parser constructor.
 /// </summary>
 private MIME_h_ContentDisposition()
 {
     m_pParameters = new MIME_h_ParameterCollection(this);
 }
Beispiel #4
0
 /// <summary>
 /// Internal parser constructor.
 /// </summary>
 private MIME_h_ContentType()
 {
     m_pParameters = new MIME_h_ParameterCollection(this);
 }
 /// <summary>
 /// Internal parser constructor.
 /// </summary>
 private MIME_h_ContentType()
 {
     m_pParameters = new MIME_h_ParameterCollection(this);
 }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="mediaType">Media type with subtype. For example <b>text/plain</b>.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>mediaType</b> is null reference.</exception>
        public MIME_h_ContentType(string mediaType)
        {
            if (mediaType == null)
            {
                throw new ArgumentNullException(mediaType);
            }

            /*string[] type_subtype = mediaType.Split(new[] {'/',}, 2);
            if (type_subtype.Length == 2)
            {
                if (type_subtype[0] == "" || !MIME_Reader.IsToken(type_subtype[0]))
                {
                    throw new ArgumentException("Invalid argument 'mediaType' value '" + mediaType +
                                                "', value must be token.");
                }
                if (type_subtype[1] == "" || !MIME_Reader.IsToken(type_subtype[1]))
                {
                    throw new ArgumentException("Invalid argument 'mediaType' value '" + mediaType +
                                                "', value must be token.");
                }

                m_Type = type_subtype[0];
                m_SubType = type_subtype[1];
            }
            else
            {
                throw new ArgumentException("Invalid argument 'mediaType' value '" + mediaType + "'.");
            }

            m_pParameters = new MIME_h_ParameterCollection(this);
            m_IsModified = true;*/

            MIME_Reader r = new MIME_Reader(mediaType);
            string type = r.Token();
            if (type == null)
            {
                throw new ParseException("Invalid Content-Type: header field value '" + mediaType + "'.");
            }
            m_Type = type;

            if (r.Char(false) != '/')
            {
                throw new ParseException("Invalid Content-Type: header field value '" + mediaType + "'.");
            }

            string subtype = r.Token();
            if (subtype == null)
            {
                //throw new ParseException("Invalid Content-Type: header field value '" + value + "'.");
                subtype = "";
            }
            m_SubType = subtype;
            m_pParameters = new MIME_h_ParameterCollection(this);
            m_pParameters.Parse(r);

            m_ParseValue = mediaType;
            m_IsModified = true;

        }
 /// <summary>
 /// Internal parser constructor.
 /// </summary>
 private MIME_h_ContentDisposition()
 {
     m_pParameters = new MIME_h_ParameterCollection(this);
 }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="dispositionType">The disposition-type. Known values are in <see cref="MIME_DispositionTypes">MIME_DispositionTypes</see>.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>dispositionType</b> is null reference.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        public MIME_h_ContentDisposition(string dispositionType)
        {
            if (dispositionType == null)
            {
                throw new ArgumentNullException("dispositionType");
            }
            if (dispositionType == string.Empty)
            {
                throw new ArgumentException("Argument 'dispositionType' value must be specified.");
            }

            m_DispositionType = dispositionType;

            m_pParameters = new MIME_h_ParameterCollection(this);
            m_IsModified = true;
        }