Path: redb-route/redb.Route.Xml/RedbRouteBuilderXmlExtensions.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.Xml/RedbRouteBuilderXmlExtensions.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Route.Core; using redb.Route.Extensions; namespace redb.Route.Xml; /// /// The DI surface: the same three loading overloads plus context.xml on /// , applied at context-start time through the standard /// hook — an ordinary ASP.NET host loads XML routes /// with one line inside AddRedbRoute(...), no Tsak required. /// public static class RedbRouteBuilderXmlExtensions { /// Loads route files by a glob pattern (or one wildcard-free path) at context start. public static RedbRouteBuilder AddXmlRoutes(this RedbRouteBuilder self, string globPattern, XmlRouteLoaderOptions? options = null) { ArgumentNullException.ThrowIfNull(self); ArgumentException.ThrowIfNullOrWhiteSpace(globPattern); return Configure(self, context => context.AddXmlRoutes(globPattern, options)); } /// Loads the named route files at context start. public static RedbRouteBuilder AddXmlRoutes(this RedbRouteBuilder self, params string[] filePaths) { ArgumentNullException.ThrowIfNull(self); if (filePaths.Length == 0) throw new ArgumentException("At least one route file path is required.", nameof(filePaths)); return Configure(self, context => context.AddXmlRoutes(filePaths)); } /// Parses the XML text at context start — tests and generated hosts. public static RedbRouteBuilder AddXmlRoutesFromContent(this RedbRouteBuilder self, string xml, string? sourceName = null, XmlRouteLoaderOptions? options = null) { ArgumentNullException.ThrowIfNull(self); ArgumentException.ThrowIfNullOrWhiteSpace(xml); return Configure(self, context => context.AddXmlRoutesFromContent(xml, sourceName, options)); } /// Loads a context.xml (components, context beans, onInit) at context start. public static RedbRouteBuilder AddXmlContext(this RedbRouteBuilder self, string filePath, XmlRouteLoaderOptions? options = null) { ArgumentNullException.ThrowIfNull(self); ArgumentException.ThrowIfNullOrWhiteSpace(filePath); return Configure(self, context => context.AddXmlContext(filePath, options)); } private static RedbRouteBuilder Configure(RedbRouteBuilder self, Action apply) { self.Services.AddSingleton(new XmlLoadConfigurator(apply)); return self; } private sealed class XmlLoadConfigurator(Action apply) : IRouteContextConfigurator { public void Configure(RouteContext context) => apply(context); } }