feat: settings window rework

This commit is contained in:
goaaats 2023-01-06 22:32:44 +01:00
parent 0dc58cce56
commit bc3dcdfad7
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
22 changed files with 1724 additions and 1084 deletions

View file

@ -14,12 +14,15 @@ public static class EnumExtensions
/// <typeparam name="TAttribute">The type of attribute to get.</typeparam>
/// <param name="value">The enum value that has an attached attribute.</param>
/// <returns>The attached attribute, if any.</returns>
public static TAttribute GetAttribute<TAttribute>(this Enum value)
public static TAttribute? GetAttribute<TAttribute>(this Enum value)
where TAttribute : Attribute
{
var type = value.GetType();
var name = Enum.GetName(type, value);
return type.GetField(name) // I prefer to get attributes this way
if (name.IsNullOrEmpty())
return null;
return type.GetField(name)?
.GetCustomAttributes(false)
.OfType<TAttribute>()
.SingleOrDefault();