Переработанная версия ядра
All checks were successful
CI / build-test (push) Successful in 42s

This commit is contained in:
2025-12-05 12:57:05 +03:00
parent ee175a35a0
commit d817417a69
81 changed files with 2335 additions and 1453 deletions

View File

@@ -0,0 +1,29 @@
namespace BotPages.Core.Routing;
/// <summary>
/// Реестр маршрутов страниц.
/// </summary>
internal sealed class RoutesRegistry
{
private readonly Dictionary<string, Type> _routes = new(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Зарегистрировать маршрут для страницы.
/// </summary>
public void Map<TPage>(string template) where TPage : Page
{
if (_routes.ContainsKey(template))
throw new InvalidOperationException($"Route '{template}' is already mapped.");
_routes[template] = typeof(TPage);
}
/// <summary>
/// Найти страницу по маршруту.
/// </summary>
public Type? Resolve(string template) => _routes.TryGetValue(template, out var t) ? t : null;
/// <summary>
/// Получить снимок всех маршрутов.
/// </summary>
public IReadOnlyDictionary<string, Type> Snapshot() => _routes;
}