Example #1
0
 public static Regex MatchEntire(Regex regex)
 {
     return(HttpRegex.Build(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "^{0}$", new object[1]
     {
         (object)regex
     })));
 }
Example #2
0
 public static Regex AtLeastOne(Regex regex)
 {
     return(HttpRegex.Build(HttpRegex.Bracket(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}+", new object[1]
     {
         (object)regex
     }))));
 }
Example #3
0
 public static Regex Capture(Regex regex, string captureName)
 {
     return(HttpRegex.Build(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "(?<{0}>{1})", new object[2]
     {
         (object)captureName,
         (object)regex
     })));
 }
        internal HttpTransferEncodingField(byte[] fieldValue)
            : base("Transfer-Encoding", (IList <byte>)fieldValue)
        {
            string @string = HttpRegex.GetString(fieldValue);
            Match  match   = HttpTransferEncodingField._regex.Match(@string);

            if (!match.Success)
            {
                return;
            }
            this.SetTransferCodings((IList <string>)Enumerable.ToArray <string>(MatchExtensions.GroupCapturesValues(match, "TransferCoding")));
        }
Example #5
0
        internal HttpTrailerField(byte[] fieldValue)
            : base("Trailer", (IList <byte>)fieldValue)
        {
            string @string = HttpRegex.GetString(fieldValue);
            Match  match   = HttpTrailerField._regex.Match(@string);

            if (!match.Success)
            {
                return;
            }
            this.SetFieldNames(MatchExtensions.GroupCapturesValues(match, "FieldName"));
        }
        internal HttpTransferEncodingField(byte[] fieldValue)
            : base(FieldName, fieldValue)
        {
            string fieldValueString = HttpRegex.GetString(fieldValue);
            Match  match            = _regex.Match(fieldValueString);

            if (!match.Success)
            {
                return;
            }

            SetTransferCodings(match.GroupCapturesValues(RegexTransferCodingGroupName).ToArray());
        }
        internal HttpTrailerField(byte[] fieldValue)
            : base(FieldName, fieldValue)
        {
            string fieldValueString = HttpRegex.GetString(fieldValue);
            Match  match            = _regex.Match(fieldValueString);

            if (!match.Success)
            {
                return;
            }

            SetFieldNames(match.GroupCapturesValues(FieldNameGroupName));
        }
        internal HttpContentTypeField(byte[] fieldValue)
            : base("Content-Type", (IList <byte>)fieldValue)
        {
            string @string = HttpRegex.GetString(fieldValue);
            Match  match   = HttpContentTypeField._regex.Match(@string);

            if (!match.Success)
            {
                return;
            }
            this.MediaType    = Enumerable.First <Capture>(Enumerable.Cast <Capture>((IEnumerable)match.Groups["MediaType"].Captures)).Value;
            this.MediaSubtype = Enumerable.First <Capture>(Enumerable.Cast <Capture>((IEnumerable)match.Groups["MediaSubType"].Captures)).Value;
            this.Parameters   = new HttpFieldParameters(MatchExtensions.GroupCapturesValues(match, "ParameterName"), MatchExtensions.GroupCapturesValues(match, "ParameterValue"));
        }
Example #9
0
        public static Regex CommaSeparatedRegex(Regex element, int minCount)
        {
            Regex regex1 = HttpRegex.Any(HttpRegex.LinearWhiteSpace);
            Regex regex2 = HttpRegex.Concat(HttpRegex.Build(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}{1}", new object[2]
            {
                (object)regex1,
                (object)element
            })), HttpRegex.AtLeast(HttpRegex.Build(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0},{1}{2}", (object)regex1, (object)regex1, (object)element)), minCount - 1));

            if (minCount > 0)
            {
                return(regex2);
            }
            return(HttpRegex.Optional(regex2));
        }
        internal HttpContentTypeField(byte[] fieldValue)
            : base(FieldName, fieldValue)
        {
            string fieldValueString = HttpRegex.GetString(fieldValue);
            Match  match            = _regex.Match(fieldValueString);

            if (!match.Success)
            {
                return;
            }

            MediaType    = match.Groups[MediaTypeGroupName].Captures.Cast <Capture>().First().Value;
            MediaSubtype = match.Groups[MediaSubTypeGroupName].Captures.Cast <Capture>().First().Value;
            Parameters   = new HttpFieldParameters(match.GroupCapturesValues(HttpRegex.ParameterNameGroupName),
                                                   match.GroupCapturesValues(HttpRegex.ParameterValueGroupName));
        }
Example #11
0
 public static Regex AtLeast(Regex regex, int minCount)
 {
     if (minCount <= 0)
     {
         return(HttpRegex.Any(regex));
     }
     if (minCount == 1)
     {
         return(HttpRegex.AtLeastOne(regex));
     }
     return(HttpRegex.Build(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "(?:{0}){{{1},}}", new object[2]
     {
         (object)regex,
         (object)minCount
     })));
 }
Example #12
0
 public static Regex Or(params Regex[] regexes)
 {
     return(HttpRegex.Build(HttpRegex.Bracket(IEnumerableExtensions.SequenceToString <Regex>((IEnumerable <Regex>)regexes, "|"))));
 }
Example #13
0
 public static Regex Build(char pattern)
 {
     return(HttpRegex.Build(pattern.ToString()));
 }
Example #14
0
 public static Regex Build(string pattern)
 {
     return(new Regex(HttpRegex.Bracket(pattern), RegexOptions.Compiled | RegexOptions.Singleline));
 }
Example #15
0
 public static string GetString(byte[] buffer)
 {
     return(HttpRegex.GetString(buffer, 0, buffer.Length));
 }