Path: redb-route/redb.Route/Predicates/OrPredicate.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/OrPredicate.cs
----
using redb.Route.Abstractions;
namespace redb.Route.Predicates;
///
/// Predicate that performs a logical OR between an expression and another predicate.
/// Returns true when either the expression evaluates to true or the predicate matches.
///
public class OrPredicate : IPredicate
{
private readonly IExpression _expression;
private readonly IPredicate _predicate;
///
/// Initializes a new instance combining an expression and a predicate with logical OR.
///
/// The expression to evaluate (left-hand side of OR).
/// The predicate to check (right-hand side of OR).
public OrPredicate(IExpression expression, IPredicate predicate)
{
_expression = expression;
_predicate = predicate;
}
///
public bool Matches(IExchange exchange)
{
bool expressionResult = _expression.Evaluate(exchange);
return expressionResult || _predicate.Matches(exchange);
}
///
public async Task MatchesAsync(IExchange exchange)
{
bool expressionResult = _expression.Evaluate(exchange);
return expressionResult || await _predicate.MatchesAsync(exchange).ConfigureAwait(false);
}
}