Path: redb-route/redb.Route/Definitions/ToDynamicDefinition.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/ToDynamicDefinition.cs ---- using redb.Route.Abstractions; using redb.Route.Processors; namespace redb.Route.Definitions; /// /// Camel-style dynamic toD(): sends the exchange to an endpoint whose URI is /// resolved per message. Accepts a ${...} template, an , /// or a factory delegate. /// /// Example: .ToD("kafka://orders-${header.region}"). /// /// public sealed class ToDynamicDefinition : ProcessorDefinition { private readonly string? _template; private readonly IExpression? _expression; private readonly Func? _uriFactory; /// Creates a dynamic-to definition from a ${...} URI template. public ToDynamicDefinition(string template) { ArgumentException.ThrowIfNullOrWhiteSpace(template); _template = template; } /// Creates a dynamic-to definition from an producing the URI. public ToDynamicDefinition(IExpression expression) { _expression = expression ?? throw new ArgumentNullException(nameof(expression)); } /// Creates a dynamic-to definition from a factory delegate producing the URI. public ToDynamicDefinition(Func uriFactory) { _uriFactory = uriFactory ?? throw new ArgumentNullException(nameof(uriFactory)); } /// public override IProcessor CreateProcessor(IRouteContext context) => new ToDynamicProcessor(CreateResolver(context)); /// The URI template, when the node was declared with one (diagnostics, XML form). public string? Template => _template; /// Builds the per-message URI resolver of this node (also used by InterceptSendToEndpoint to learn the target URI). internal DynamicEndpointResolver CreateResolver(IRouteContext context) => _template is not null ? DynamicEndpointResolver.FromTemplate(context, _template) : _expression is not null ? DynamicEndpointResolver.FromExpression(context, _expression) : new DynamicEndpointResolver(context, _uriFactory!); }