public void Add(RouteToken record) { _records.Add(record); var recordIndex = _records.Count; var hashForSize = _hashes.LastOrDefault().MergeHash(record.Hash); _hashes.Add(hashForSize); if (Equals(record, Wildcard)) { _regexPatternTokens.Add($"({EscapeSymbol}\\d+{EscapeSymbol})"); if (!_recursiveStart.HasValue) { _recursiveStart = recordIndex - 1; } _recursiveEnd = recordIndex; } else if (Equals(record, WildcardRecursive)) { _regexPatternTokens.Add($"({EscapeSymbol}\\d+{EscapeSymbol})*?"); if (!_recursiveStart.HasValue) { _recursiveStart = recordIndex - 1; } _recursiveEnd = recordIndex; } else { _regexPatternTokens.Add($"({record.TokenString})"); } _regexInputTokens.Add(record.TokenString); }
static RouteTokenSequenceBuilder() { Wildcard = Route.EnsureTokenCached(Route.Wildcard); WildcardRecursive = Route.EnsureTokenCached(Route.WildcardRecursive); }