Files
mixtape/zero.Core/Routing/IRouteProvider.cs
T

66 lines
1.9 KiB
C#
Raw Normal View History

2020-10-23 15:50:59 +02:00
using Raven.Client.Documents.Session;
using System;
2020-10-26 13:59:46 +01:00
using System.Collections.Generic;
using System.Linq.Expressions;
2020-10-23 15:50:59 +02:00
using System.Threading.Tasks;
namespace zero.Core.Routing
{
public interface IRouteProvider<T> : IRouteProvider
2020-10-23 15:50:59 +02:00
{
/// <summary>
/// Find URL for an entity
/// </summary>
2021-05-04 17:23:52 +02:00
Task<Route> GetRoute(IAsyncDocumentSession session, T model, object parameters = null);
2020-10-23 15:50:59 +02:00
/// <summary>
/// Find URLs for mulitple entities
/// </summary>
2021-05-04 17:23:52 +02:00
Task<Dictionary<T, Route>> GetRoutes(IAsyncDocumentSession session, IEnumerable<T> models, object parameters = null);
2020-10-23 15:50:59 +02:00
/// <summary>
2020-10-26 13:59:46 +01:00
/// Generate unique route ID for a model
2020-10-23 15:50:59 +02:00
/// </summary>
2021-05-03 12:13:49 +02:00
string GetRouteId(T model, object parameters = null);
2020-10-23 15:50:59 +02:00
}
public interface IRouteProvider
{
string Alias { get; }
Type[] AffectedTypes { get; }
/// <summary>
/// Map a route to an MVC endpoint
/// </summary>
RouteProviderEndpoint MapEndpoint(IResolvedRoute route);
2020-10-26 13:59:46 +01:00
2020-10-23 15:50:59 +02:00
/// <summary>
/// Resolve a route and load optional dependencies into it.
/// This is the data which is passed to the specified controller action.
/// </summary>
2021-05-04 17:23:52 +02:00
Task<IResolvedRoute> ResolveRoute(IAsyncDocumentSession session, Route route);
2020-10-23 15:50:59 +02:00
/// <summary>
/// Find URL for an entity
/// </summary>
2021-05-04 17:23:52 +02:00
Task<Route> GetRoute(IAsyncDocumentSession session, object model, object parameters = null);
2020-10-23 15:50:59 +02:00
/// <summary>
/// Find URLs for mulitple entities
/// </summary>
2021-05-04 17:23:52 +02:00
Task<Dictionary<object, Route>> GetRoutes(IAsyncDocumentSession session, IEnumerable<object> models, object parameters = null);
2020-10-23 15:50:59 +02:00
/// <summary>
2020-10-26 13:59:46 +01:00
/// Rebuild all routes for this provider so they can be hydrated into the database
/// </summary>
2021-05-04 17:23:52 +02:00
Task<IList<Route>> GetAllRoutes(IAsyncDocumentSession session);
2020-10-26 13:59:46 +01:00
/// <summary>
/// Generate unique route ID for a model
2020-10-23 15:50:59 +02:00
/// </summary>
2021-05-03 12:13:49 +02:00
string GetRouteId(object model, object parameters = null);
2020-10-23 15:50:59 +02:00
}
}