예제 #1
0
        public IGlobBuilder DirectoryWildcard(PathSeparatorKind?leadingSeparatorKind = PathSeparatorKind.ForwardSlash, PathSeparatorKind?trailingSeparatorKind = PathSeparatorKind.ForwardSlash)
        {
            PathSeparatorToken trailingSep = null;
            PathSeparatorToken leadingSep  = null;

            if (trailingSeparatorKind == null)
            {
                trailingSep = null;
            }
            else
            {
                switch (trailingSeparatorKind)
                {
                case PathSeparatorKind.BackwardSlash:
                    trailingSep = new PathSeparatorToken('\\');
                    break;

                case PathSeparatorKind.ForwardSlash:
                    trailingSep = new PathSeparatorToken('/');
                    break;

                default:
                    break;
                }
            }

            if (leadingSeparatorKind == null)
            {
                leadingSep = null;
            }
            else
            {
                switch (leadingSeparatorKind)
                {
                case PathSeparatorKind.BackwardSlash:
                    leadingSep = new PathSeparatorToken('\\');
                    break;

                case PathSeparatorKind.ForwardSlash:
                    leadingSep = new PathSeparatorToken('/');
                    break;

                default:
                    break;
                }
            }

            _tokens.Add(new WildcardDirectoryToken(leadingSep, trailingSep));


            return(this);
        }
예제 #2
0
        private IGlobToken ReadDirectoryWildcardToken(GlobStringReader reader, PathSeparatorToken leadingPathSeparatorToken)
        {
            reader.ReadChar();

            if (GlobStringReader.IsPathSeparator(reader.PeekChar()))
            {
                reader.ReadChar();
                var trailingSeparator = ReadPathSeparatorToken(reader);
                return(new WildcardDirectoryToken(leadingPathSeparatorToken, trailingSeparator));
            }

            return(new WildcardDirectoryToken(leadingPathSeparatorToken, null)); // this shouldn't happen unless a pattern ends with ** which is weird. **sometext is not legal.
        }
예제 #3
0
        public void Visit(PathSeparatorToken token)
        {
            Success = false;
            var read = _Reader.Read();

            if (read == -1)
            {
                return;
            }

            var currentChar = (char)read;

            if (!GlobStringReader.IsPathSeparator(currentChar))
            {
                return;
            }

            AddMatch(new GlobTokenMatch()
            {
                Token = token, Value = currentChar.ToString()
            });
        }
예제 #4
0
 void IGlobTokenVisitor.Visit(PathSeparatorToken token)
 {
     AddMatchGenerator(new PathSeparatorMatchGenerator(token, _random));
 }
예제 #5
0
 public IGlobTokenEvaluator CreateTokenEvaluator(PathSeparatorToken token)
 {
     return(new PathSeparatorTokenEvaluator(token));
 }
예제 #6
0
 public void Visit(PathSeparatorToken token)
 {
     AddEvaluator(_evaluatorFactory.CreateTokenEvaluator(token));
 }
예제 #7
0
 public PathSeparatorMatchGenerator(PathSeparatorToken token, Random _random)
 {
     this.token   = token;
     this._random = _random;
 }
예제 #8
0
 public PathSeparatorTokenEvaluator(PathSeparatorToken token)
 {
     _token = token;
 }
예제 #9
0
 void IGlobTokenVisitor.Visit(PathSeparatorToken token)
 {
     _stringBuilder.Append(token.Value);
 }
예제 #10
0
 void IGlobTokenVisitor.Visit(PathSeparatorToken token)
 {
     _stringBuilder.Append(@"[/\\]");
 }
예제 #11
0
 public WildcardDirectoryToken(PathSeparatorToken leadingPathSeparator, PathSeparatorToken trailingPathSeparator)
 {
     TrailingPathSeparator = trailingPathSeparator;
     LeadingPathSeparator  = leadingPathSeparator;
 }