Path: redb-route/redb.Route/Expressions/BodyExpression.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/Expressions/BodyExpression.cs
----
using System;
using redb.Route.Abstractions;
namespace redb.Route.Expressions;
///
/// Expression for accessing the message body in an .
///
///
/// Allows extracting and converting the message body
/// for use in predicates and routing logic.
///
public class BodyExpression : Expression
{
///
/// Initializes a new instance of the class.
///
public BodyExpression()
{
}
///
/// Thrown when is null.
/// Thrown when the body type is not compatible with .
public override T Evaluate(IExchange exchange)
{
if (exchange == null)
throw new ArgumentNullException(nameof(exchange));
return exchange.In.getBody();
}
///
/// Thrown when is null.
public override void SetValue(IExchange exchange, object value)
{
if (exchange == null)
throw new ArgumentNullException(nameof(exchange));
exchange.In.setBody(value);
}
///
public override string ToTemplateString() => "${body}";
}