Path: redb-route/redb.Route/Definitions/SetPropertiesDefinition.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/Definitions/SetPropertiesDefinition.cs
----
using redb.Route.Abstractions;
using redb.Route.Processors;
namespace redb.Route.Definitions;
///
/// Sets several exchange properties in one step (one Message History entry), the property twin of
/// . A value that is an is evaluated per
/// message, a Func<IExchange, object?> is invoked, anything else is a constant. The
/// properties are set in order, so a later value may read an earlier one.
///
public sealed class SetPropertiesDefinition : ProcessorDefinition
{
/// Creates the node.
public SetPropertiesDefinition(IReadOnlyList<(string Name, object? Value)> properties)
{
ArgumentNullException.ThrowIfNull(properties);
if (properties.Count == 0) throw new ArgumentException("At least one property is required.", nameof(properties));
foreach (var (name, _) in properties)
ArgumentException.ThrowIfNullOrWhiteSpace(name);
Properties = properties;
}
/// Property names and value sources.
public IReadOnlyList<(string Name, object? Value)> Properties { get; }
///
public override IProcessor CreateProcessor(IRouteContext context)
=> new DelegateProcessor(exchange =>
{
foreach (var (name, value) in Properties)
exchange.Properties[name] = value switch
{
IExpression expression => expression.Evaluate