/// <summary>
        /// Read name value parameters from the given segment
        /// </summary>
        /// <param name="parameterText"></param>
        /// <returns></returns>
        public static KeyValuePair <string, string> ReadNameValue(StringSegment parameterText)
        {
            CharReader reader      = new CharReader(parameterText); // Struct. Cheap
            int        nameStartAt = parameterText.StartIndex;
            string     name;
            string     value;

            if (!reader.ReadTo(MimeFieldParameters.NameValueSeparator, true))
            {
                // We ran out of segment. Treat the entire segment as a value with no name
                value = reader.Substring(nameStartAt, reader.Position);
                return(new KeyValuePair <string, string>(string.Empty, value));
            }
            name = reader.Substring(nameStartAt, reader.Position - 1);
            if (string.IsNullOrEmpty(name))
            {
                throw new MimeException(MimeError.InvalidFieldParameter);
            }
            value = ReadValue(ref reader);

            return(new KeyValuePair <string, string>(name.TrimStart(), value));
        }
        static string ReadValue(ref CharReader reader)
        {
            int startAt = reader.Position + 1;
            int endAt;

            reader.ReadTo(MimeFieldParameters.NameValueSeparator, true, MailStandard.DQUOTE);
            // We're forgiving here
            if (reader.Current() == MailStandard.DQUOTE)
            {
                startAt++;
                endAt = reader.Position - 1;
            }
            else
            {
                endAt = reader.Position;
            }
            string value = reader.Substring(startAt, endAt);

            if (string.IsNullOrEmpty(value))
            {
                return(string.Empty);
            }
            return(UnescapeQuotes(value));
        }