2020-05-13 14:06:11 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2021-09-03 00:23:39 +02:00
|
|
|
using System.Linq;
|
2020-05-13 14:06:11 +02:00
|
|
|
using zero.Core.Entities;
|
|
|
|
|
|
|
|
|
|
namespace zero.Core.Options
|
|
|
|
|
{
|
|
|
|
|
public class PageOptions : ZeroBackofficeCollection<PageType>, IZeroCollectionOptions
|
|
|
|
|
{
|
|
|
|
|
public PageOptions()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-19 13:07:38 +01:00
|
|
|
public string Root { get; set; } = Constants.Pages.DefaultRootPageTypeAlias;
|
|
|
|
|
|
2020-05-13 14:06:11 +02:00
|
|
|
|
|
|
|
|
public void Add<T>(PageType<T> pageType) where T : Page, new()
|
|
|
|
|
{
|
|
|
|
|
Items.Add(PageType.Convert(pageType));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-12-04 13:18:12 +01:00
|
|
|
public void Add<T>(string alias, string name, string description, string icon) where T : Page, new()
|
2020-05-13 14:06:11 +02:00
|
|
|
{
|
|
|
|
|
Items.Add(new PageType(typeof(T))
|
|
|
|
|
{
|
|
|
|
|
Alias = alias,
|
|
|
|
|
Name = name,
|
|
|
|
|
Description = description,
|
2020-12-04 13:18:12 +01:00
|
|
|
Icon = icon
|
2020-05-13 14:06:11 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-12-04 13:18:12 +01:00
|
|
|
public void Add(Type type, string alias, string name, string description, string icon)
|
2020-05-13 14:06:11 +02:00
|
|
|
{
|
|
|
|
|
Items.Add(new PageType(type)
|
|
|
|
|
{
|
|
|
|
|
Alias = alias,
|
|
|
|
|
Name = name,
|
|
|
|
|
Description = description,
|
2020-12-04 13:18:12 +01:00
|
|
|
Icon = icon
|
2020-05-13 14:06:11 +02:00
|
|
|
});
|
|
|
|
|
}
|
2021-09-03 00:23:39 +02:00
|
|
|
|
|
|
|
|
public PageType GetByAlias(string alias)
|
|
|
|
|
{
|
|
|
|
|
return Items.FirstOrDefault(x => x.Alias == alias);
|
|
|
|
|
}
|
2020-05-13 14:06:11 +02:00
|
|
|
}
|
|
|
|
|
}
|