namespace zero.Routing;
[RavenCollection("Routes")]
public class Route : ZeroIdEntity
{
public Route() { }
public Route(string providerAlias)
{
ProviderAlias = providerAlias;
}
public Route(string id, string url, string providerAlias)
{
Id = id;
Url = url;
ProviderAlias = providerAlias;
}
///
/// Id of the referenced entity
///
public string ReferenceId { get; set; }
///
/// Generated URL based on the URL provider
///
public string Url { get; set; }
///
/// Alias of the URL provider which generated this route
///
public string ProviderAlias { get; set; }
///
/// Enable this property so all routes are catched which start with this Url
///
public bool AllowSuffix { get; set; }
///
/// Additional parameters
///
public Dictionary Params { get; set; } = new();
///
/// Route dependencies can be used for cache busting
///
public List Dependencies { get; set; } = new();
///
/// Update an existing route with regenerated data
///
public virtual Route Update(Route newRoute)
{
ReferenceId = newRoute.ReferenceId;
Url = newRoute.Url;
AllowSuffix = newRoute.AllowSuffix;
Params = newRoute.Params;
Dependencies = newRoute.Dependencies;
return this;
}
///
/// Create a new route
///
public static Route Create(string id, string providerAlias)
{
return new(providerAlias) { Id = id };
}
}