Добавлено автоматические заполнение маршрутов для страниц
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
namespace BotPages.Core.Routing;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BotPages.Core.Routing;
|
||||
|
||||
/// <summary>
|
||||
/// Реестр маршрутов страниц.
|
||||
@@ -26,4 +28,14 @@ internal sealed class RoutesRegistry
|
||||
/// Получить снимок всех маршрутов.
|
||||
/// </summary>
|
||||
public IReadOnlyDictionary<string, Type> Snapshot() => _routes;
|
||||
|
||||
internal void Map(Type? type)
|
||||
{
|
||||
foreach(var attr in type.GetCustomAttributes<RouteAttribute>(inherit: true))
|
||||
{
|
||||
_routes.Add(attr.Template, type);
|
||||
}
|
||||
|
||||
_routes.Add(type.FullName, type);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user