Exemple #1
0
        public static HeaderField Parse(string value)
        {
            Match match = headerRegex.Match(value);
            if (!match.Success)
                throw new FormatException();

            string fieldName = match.Groups["name"].Value.Trim();
            string fieldValue = match.Groups["value"].Value.Trim();
            HeaderField field = new HeaderField(fieldName, fieldValue);

            for (int i = 0; i < match.Groups["pname"].Captures.Count; i++)
            {
                string parameterName = match.Groups["pname"].Captures[i].Value.Trim();
                string parameterValue = match.Groups["pvalue"].Captures[i].Value.Trim();
                field.AddParameter(parameterName, parameterValue);
            }

            return field;
        }
Exemple #2
0
        public static HeaderField Parse(string value)
        {
            Match match = headerRegex.Match(value);

            if (!match.Success)
            {
                throw new FormatException();
            }

            string      fieldName  = match.Groups["name"].Value.Trim();
            string      fieldValue = match.Groups["value"].Value.Trim();
            HeaderField field      = new HeaderField(fieldName, fieldValue);

            for (int i = 0; i < match.Groups["pname"].Captures.Count; i++)
            {
                string parameterName  = match.Groups["pname"].Captures[i].Value.Trim();
                string parameterValue = match.Groups["pvalue"].Captures[i].Value.Trim();
                field.AddParameter(parameterName, parameterValue);
            }

            return(field);
        }