mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-15 20:37:42 +01:00
feat: settings window rework
This commit is contained in:
parent
0dc58cce56
commit
bc3dcdfad7
22 changed files with 1724 additions and 1084 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue