CodeLiturgy.Dashboard/CodeLiturgy.Views/RazorUtils/RouteRecord.cs

61 lines
1.7 KiB
C#
Raw Permalink Normal View History

2022-10-30 19:48:24 +03:00
namespace CodeLiturgy.Views.Utils
2022-09-26 04:05:23 +03:00
{
/// <summary>
/// Url container.
/// </summary>
2022-11-17 00:17:44 +03:00
public class Url
2022-09-26 04:05:23 +03:00
{
/// <summary>
/// Name of the URL
/// </summary>
public readonly string Name;
/// <summary>
/// Location of the URL (URI).
/// </summary>
public readonly string Location;
2022-11-17 00:17:44 +03:00
/// <summary>
/// Url constructor.
/// </summary>
/// <param name="name">Name of the URL</param>
/// <param name="location">Location of the URL (URI).</param>
2022-11-17 00:17:44 +03:00
public Url(string name, string location)
{
Name = name;
Location = location;
}
}
/// <summary>
/// A record representing a main view on the site
/// </summary>
/// <param name="Name">The name of the view</param>
/// <param name="RouteKey">A unique key for this view.</param>
/// <param name="Location">The unique URL for this view.</param>
/// <param name="ControllerName">Controller name.</param>
/// <param name="Children">Children views of this view.</param>
/// <param name="ViewType">Type of this view.</param>
2022-11-17 00:17:44 +03:00
public record RouteRecord(string Name, string RouteKey, string Location, string ControllerName, List<RouteRecord> Children, ViewType ViewType = ViewType.Undefined)
{
/// <summary>
/// Children to Url List.
/// </summary>
/// <returns></returns>
2022-11-17 00:17:44 +03:00
public List<Url> ChildrenToUrl()
{
return Children.Select(x => x.ToUrl()).ToList();
}
public Url ToUrl()
{
return new Url(Name, Location);
}
public Url ToUrl(string name)
{
return new Url(name, Location);
}
2022-09-26 04:05:23 +03:00
}
}