Ejemplo n.º 1
0
        /// <summary>
        /// Converts <paramref name="wildcardPattern"/> into a DOS wildcard.
        /// </summary>
        internal static string Parse(WildcardPattern wildcardPattern)
        {
            var parser = new WildcardPatternToDosWildcardParser();

            WildcardPatternParser.Parse(wildcardPattern, parser);
            return(parser._result.ToString());
        }
Ejemplo n.º 2
0
 public static WildcardPatternMatcher.PatternElement[] Parse(WildcardPattern pattern, WildcardPatternMatcher.CharacterNormalizer characterNormalizer)
 {
     WildcardPatternMatcher.MyWildcardPatternParser parser = new WildcardPatternMatcher.MyWildcardPatternParser {
         _characterNormalizer = characterNormalizer,
         _regexOptions        = WildcardPatternToRegexParser.TranslateWildcardOptionsIntoRegexOptions(pattern.Options)
     };
     WildcardPatternParser.Parse(pattern, parser);
     return(parser._patternElements.ToArray());
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses a <paramref name="wildcardPattern"/> into a <see cref="Regex"/>
        /// </summary>
        /// <param name="wildcardPattern">Wildcard pattern to parse.</param>
        /// <returns>Regular expression equivalent to <paramref name="wildcardPattern"/></returns>
        public static Regex Parse(WildcardPattern wildcardPattern)
        {
            WildcardPatternToRegexParser parser = new WildcardPatternToRegexParser();

            WildcardPatternParser.Parse(wildcardPattern, parser);
            try
            {
                return(new Regex(parser._regexPattern.ToString(), parser._regexOptions));
            }
            catch (ArgumentException)
            {
                throw WildcardPatternParser.NewWildcardPatternException(wildcardPattern.Pattern);
            }
        }