2023-06-19 12:56:40 -04:00
|
|
|
using System;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Reflection;
|
|
|
|
|
2023-06-01 00:03:23 -04:00
|
|
|
namespace vassago.Models;
|
|
|
|
|
|
|
|
public static class Enumerations
|
|
|
|
{
|
2023-06-19 12:56:40 -04:00
|
|
|
public enum LewdnessFilterLevel
|
2023-06-01 00:03:23 -04:00
|
|
|
{
|
2023-06-19 12:56:40 -04:00
|
|
|
[Description("this is a christian minecraft server 🙏")]
|
|
|
|
Strict,
|
|
|
|
[Description("G-Rated")]
|
|
|
|
G,
|
|
|
|
[Description("polite company")]
|
|
|
|
Moderate,
|
|
|
|
[Description(";) ;) ;)")]
|
2023-11-30 12:50:51 -05:00
|
|
|
Unrestricted
|
2023-06-19 12:56:40 -04:00
|
|
|
}
|
|
|
|
public enum MeannessFilterLevel
|
|
|
|
{
|
|
|
|
[Description("good vibes only")]
|
|
|
|
Strict,
|
2023-07-04 13:31:19 -04:00
|
|
|
[Description("a bit cheeky")]
|
|
|
|
Medium,
|
2023-11-30 12:50:51 -05:00
|
|
|
[Description("387.44m mi of printed circuits")]
|
2023-06-19 12:56:40 -04:00
|
|
|
Unrestricted
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:33:58 -05:00
|
|
|
public enum ChannelType
|
|
|
|
{
|
|
|
|
[Description("Normal")]
|
|
|
|
Normal,
|
|
|
|
[Description("DM")]
|
|
|
|
DM,
|
|
|
|
[Description("protocol psuedo-channel")]
|
|
|
|
Protocol,
|
|
|
|
[Description("organizational psuedo-channel")]
|
|
|
|
OU
|
|
|
|
}
|
|
|
|
|
2023-06-19 12:56:40 -04:00
|
|
|
public static string GetDescription<T>(this T enumerationValue)
|
|
|
|
where T : struct
|
2023-06-01 00:03:23 -04:00
|
|
|
{
|
2023-06-19 12:56:40 -04:00
|
|
|
Type type = enumerationValue.GetType();
|
|
|
|
if (!type.IsEnum)
|
|
|
|
{
|
2024-06-16 18:10:49 -04:00
|
|
|
throw new ArgumentException("EnumerationValue must be of Enum type", nameof(enumerationValue));
|
2023-06-19 12:56:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//Tries to find a DescriptionAttribute for a potential friendly name
|
|
|
|
//for the enum
|
|
|
|
MemberInfo[] memberInfo = type.GetMember(enumerationValue.ToString());
|
|
|
|
if (memberInfo != null && memberInfo.Length > 0)
|
2023-06-01 00:03:23 -04:00
|
|
|
{
|
2023-06-19 12:56:40 -04:00
|
|
|
object[] attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
|
|
|
|
|
|
|
|
if (attrs != null && attrs.Length > 0)
|
|
|
|
{
|
|
|
|
//Pull out the description value
|
|
|
|
return ((DescriptionAttribute)attrs[0]).Description;
|
|
|
|
}
|
2023-06-01 00:03:23 -04:00
|
|
|
}
|
2023-06-19 12:56:40 -04:00
|
|
|
//If we have no description attribute, just return the ToString of the enum
|
|
|
|
return enumerationValue.ToString();
|
2023-06-01 00:03:23 -04:00
|
|
|
}
|
|
|
|
}
|