Path: redb-route/redb.Route/Processors/ExpressionProcessors.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/Processors/ExpressionProcessors.cs
----
using System.Collections;
using Microsoft.Extensions.Logging;
using redb.Route.Abstractions;
using redb.Route.Expressions;
namespace redb.Route.Processors;
///
/// Resolves a string template: single ${expr} preserves CLR type,
/// composite templates (with surrounding text) return string.
///
internal static class ExpressionHelper
{
internal static object? ResolveTypedOrTemplate(string template, IExchange exchange)
=> ExpressionResolver.ResolveTypedOrTemplate(template, exchange);
}
///
/// Processor that evaluates an and sets the result as the exchange body.
/// Used by the DSL .SetBody(IExpression) and .Transform(IExpression).
///
public sealed class ExpressionBodyProcessor : IProcessor
{
private readonly IExpression _expression;
/// Creates a new instance with the specified expression.
/// Expression producing the new body value.
public ExpressionBodyProcessor(IExpression expression)
{
_expression = expression ?? throw new ArgumentNullException(nameof(expression));
}
///
public Task Process(IExchange exchange, CancellationToken ct = default)
{
var result = _expression.Evaluate