Path: redb-route/redb.Route/Predicates/ContainsPredicate.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Predicates/ContainsPredicate.cs ---- using System.Collections; using redb.Route.Abstractions; namespace redb.Route.Predicates; /// /// Predicate that checks whether a string contains a substring or a collection contains an element. /// public class ContainsPredicate : IPredicate { private readonly IExpression _expression; private readonly object _value; /// /// Initializes a new instance with the specified expression and value to search for. /// /// The expression to evaluate. /// The substring or element to look for. public ContainsPredicate(IExpression expression, object value) { _expression = expression; _value = value; } /// public bool Matches(IExchange exchange) { var result = _expression.Evaluate(exchange); if (result is string str && _value is string substr) return str.Contains(substr); if (result is IEnumerable enumerable) { foreach (var item in enumerable) { if (object.Equals(item, _value)) return true; } } return false; } /// public Task MatchesAsync(IExchange exchange) => Task.FromResult(Matches(exchange)); }