galaeth-draft/Galaeth.Core/Extensions/UserRoleExtensions.cs

32 lines
891 B
C#
Raw Permalink Normal View History

2024-11-17 10:31:01 +01:00
using Galaeth.Core.Constants;
namespace Galaeth.Core.Extensions;
/// <summary>
/// <see cref="UserRole"/> extensions.
/// </summary>
public static class UserRoleExtensions
{
/// <summary>
/// Return a collection of roles a role is entitled to.
/// </summary>
/// <param name="role">The role to query.</param>
/// <returns>A collection of roles the role is entitled to.</returns>
public static UserRole[] UserRoleEntitlement(this UserRole role)
{
switch (role)
{
default:
case UserRole.Normal:
return
[UserRole.Normal];
case UserRole.Moderator:
return
[UserRole.Normal, UserRole.Moderator];
case UserRole.Root:
return
[UserRole.Normal, UserRole.Moderator, UserRole.Root];
}
}
}