Path: redb-route/redb.Route.GenericFile/GenericFileFilterResolution.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.GenericFile/GenericFileFilterResolution.cs
----
using redb.Route.Abstractions;
using redb.Route.Extensions;
namespace redb.Route.GenericFile;
///
/// Turns filter=#myFilter into the filter instance the consumer calls. Shared by the
/// file-based components so the reference is spelled and resolved the same way everywhere, and so
/// an unknown name fails at endpoint creation instead of quietly polling everything.
///
public static class GenericFileFilterResolution
{
///
/// Resolves from the route registry into
/// . Does nothing when no name was given
/// or when the instance was already supplied in code.
///
/// Endpoint options carrying the reference.
/// Route context owning the registry.
public static void ResolveFilter(this GenericFileEndpointOptions options, IRouteContext? context)
{
ArgumentNullException.ThrowIfNull(options);
if (string.IsNullOrEmpty(options.Filter) || options.FilterInstance is not null)
return;
// The leading '#' is Camel's spelling of "this is a registry name"; both forms are accepted
// so a route ported from Camel keeps working, and a name that is not registered fails loud.
var name = options.Filter.StartsWith('#') ? options.Filter[1..] : options.Filter;
options.FilterInstance = context.GetRequiredFromRegistry(name);
}
}