34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace Moonlight.Frontend.Configuration;
|
|
|
|
public class SystemSettingsOptions
|
|
{
|
|
public IReadOnlyList<SystemSettingsPage> Components => InnerComponents;
|
|
|
|
private readonly List<SystemSettingsPage> InnerComponents = new();
|
|
|
|
public void Add<TIcon, TComponent>(string name, string description, int order)
|
|
where TIcon : ComponentBase where TComponent : ComponentBase
|
|
=> Add(name, description, order, typeof(TIcon), typeof(TComponent));
|
|
|
|
public void Add(string name, string description, int order, Type iconComponent, Type component)
|
|
=> InnerComponents.Add(new SystemSettingsPage(name, description, order, iconComponent, component));
|
|
|
|
public void Remove<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TComponent>()
|
|
where TComponent : ComponentBase
|
|
=> Remove(typeof(TComponent));
|
|
|
|
public void Remove(Type componentType)
|
|
=> InnerComponents.RemoveAll(x => x.ComponentType == componentType);
|
|
}
|
|
|
|
public record SystemSettingsPage(
|
|
string Name,
|
|
string Description,
|
|
int Order,
|
|
[property: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
|
|
Type IconComponentType,
|
|
Type ComponentType
|
|
); |