61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
namespace CodeLiturgy.Views.Utils
|
|
{
|
|
/// <summary>
|
|
/// Url container.
|
|
/// </summary>
|
|
public class Url
|
|
{
|
|
/// <summary>
|
|
/// Name of the URL
|
|
/// </summary>
|
|
public readonly string Name;
|
|
/// <summary>
|
|
/// Location of the URL (URI).
|
|
/// </summary>
|
|
public readonly string Location;
|
|
|
|
/// <summary>
|
|
/// Url constructor.
|
|
/// </summary>
|
|
/// <param name="name">Name of the URL</param>
|
|
/// <param name="location">Location of the URL (URI).</param>
|
|
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>
|
|
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>
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|