Path: redb-route/redb.Route.Templates/TemplateArgs.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.Templates/TemplateArgs.cs ---- using redb.Route.Abstractions; using redb.Route.Expressions; namespace redb.Route.Templates; /// /// Named arguments of a payload step — the analog of WSO2 PayloadFactory <arg>, but by /// name instead of position: args.Set("customer", "header.customerId") is read in the template /// as {{ args.customer }}. Argument expressions are the route expression language and are /// evaluated on the message before rendering, which keeps the template itself an almost /// static document a non-programmer can edit. /// public sealed class TemplateArgs { private readonly Dictionary _expressions = new(StringComparer.Ordinal); private readonly Dictionary _constants = new(StringComparer.Ordinal); /// Argument computed from a route-language expression ("header.amount * header.qty"); the expression is compiled now, so a typo fails at Start(). public TemplateArgs Set(string name, string expression) { ArgumentException.ThrowIfNullOrWhiteSpace(name); ArgumentException.ThrowIfNullOrWhiteSpace(expression); return Set(name, new StringExpression(expression)); } /// Argument computed from an . public TemplateArgs Set(string name, IExpression expression) { ArgumentException.ThrowIfNullOrWhiteSpace(name); ArgumentNullException.ThrowIfNull(expression); _constants.Remove(name); _expressions[name] = expression; return this; } /// Constant argument (XML form <arg name="channel" value="email"/>). public TemplateArgs SetValue(string name, object? value) { ArgumentException.ThrowIfNullOrWhiteSpace(name); _expressions.Remove(name); _constants[name] = value; return this; } /// Argument names, for diagnostics. public IEnumerable Names => _expressions.Keys.Concat(_constants.Keys); /// Evaluates every argument against the exchange. internal Dictionary Evaluate(IExchange exchange) { var result = new Dictionary(_constants, StringComparer.Ordinal); foreach (var (name, expression) in _expressions) result[name] = expression.Evaluate(exchange); return result; } }