galaeth-draft/Galaeth.Core/Extensions/UserRoleExtensions.cs
2024-11-17 09:31:01 +00:00

32 lines
891 B
C#

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];
}
}
}