Path: redb-route/redb.Route/Abstractions/IExpression.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/Abstractions/IExpression.cs
----
namespace redb.Route.Abstractions;
///
/// Represents an expression that can be evaluated against an exchange context.
/// Expressions extract or compute values from a message exchange.
/// Used for content-based routing, transformations, and predicate construction.
///
public interface IExpression
{
///
/// Evaluates the expression and returns the result cast to .
///
/// Target return type.
/// The exchange to evaluate against.
/// Evaluation result converted to .
T Evaluate(IExchange exchange);
/// Creates a predicate that checks equality of this expression's result with the given value.
IPredicate isEqualTo(object value);
/// Creates a "greater than" predicate.
IPredicate isGreaterThan(object value);
/// Creates a "less than" predicate.
IPredicate isLessThan(object value);
/// Creates a "greater than or equal" predicate.
IPredicate isGreaterThanOrEqualTo(object value);
/// Creates a "less than or equal" predicate.
IPredicate isLessThanOrEqualTo(object value);
/// Creates a "between" predicate (inclusive).
IPredicate isBetween(object low, object high);
/// Creates a "contains" predicate (for strings and collections).
IPredicate contains(object value);
/// Creates a "starts with" predicate (for strings).
IPredicate startsWith(object value);
/// Creates an "ends with" predicate (for strings).
IPredicate endsWith(object value);
/// Creates a regex-match predicate.
IPredicate regex(string pattern);
/// Creates an "in set" predicate.
IPredicate In(params object[] values);
/// Creates a "not equal" predicate.
IPredicate isNotEqualTo(object value);
/// Creates an "is null" predicate.
IPredicate isNull();
/// Creates an "is not null" predicate.
IPredicate isNotNull();
/// Creates a logical AND predicate combining this expression with another predicate.
IPredicate and(IPredicate predicate);
/// Creates a logical OR predicate combining this expression with another predicate.
IPredicate or(IPredicate predicate);
/// Creates a logical NOT predicate negating this expression.
IPredicate not();
///
/// Sets a value in the exchange according to this expression's semantics.
/// For example, sets a header,
/// sets the body.
///
/// The target exchange.
/// The value to set.
void SetValue(IExchange exchange, object value);
///
/// Serializes this expression to a ${...} template string suitable for URI parameters.
///
/// Template string representation, e.g. ${header.orderId}.
/// Thrown when the expression cannot be serialized (e.g. delegate-based).
string ToTemplateString();
}