예제 #1
0
        public void Add(RouteToken record)
        {
            _records.Add(record);

            var recordIndex = _records.Count;

            _hash = _hash.MergeHash(record.Hash);

            var recordTokenString = record.Token.ToString();

            if (Equals(record, Wildcard))
            {
                _regexPatternTokens.Add("(?<" + recordIndex + ">\\d+?)");
                if (!_recursiveStart.HasValue)
                {
                    _recursiveStart = recordIndex - 1;
                }
                _recursiveEnd = recordIndex;
            }
            else if (Equals(record, WildcardRecursive))
            {
                _regexPatternTokens.Add("(?<" + recordIndex + ">.+?)");
                if (!_recursiveStart.HasValue)
                {
                    _recursiveStart = recordIndex - 1;
                }
                _recursiveEnd = recordIndex;
            }
            else
            {
                _regexPatternTokens.Add("(?<" + recordIndex + ">" + recordTokenString + ")");
            }

            _regexInputTokens.Add(recordTokenString);
        }
예제 #2
0
 static RouteTokenSequenceBuilder()
 {
     Wildcard          = Route.EnsureTokenCached(Route.Wildcard);
     WildcardRecursive = Route.EnsureTokenCached(Route.WildcardRecursive);
 }