mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-16 12:57:44 +01:00
Revert "refactor(Dalamud): switch to file-scoped namespaces"
This reverts commit b5f34c3199.
This commit is contained in:
parent
d473826247
commit
1561fbac00
325 changed files with 45549 additions and 45209 deletions
|
|
@ -1,27 +1,28 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Dalamud.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for enums.
|
||||
/// </summary>
|
||||
public static class EnumExtensions
|
||||
namespace Dalamud.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an attribute on an enum.
|
||||
/// Extension methods for enums.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
where TAttribute : Attribute
|
||||
public static class EnumExtensions
|
||||
{
|
||||
var type = value.GetType();
|
||||
var name = Enum.GetName(type, value);
|
||||
return type.GetField(name) // I prefer to get attributes this way
|
||||
.GetCustomAttributes(false)
|
||||
.OfType<TAttribute>()
|
||||
.SingleOrDefault();
|
||||
/// <summary>
|
||||
/// Gets an attribute on an enum.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
var type = value.GetType();
|
||||
var name = Enum.GetName(type, value);
|
||||
return type.GetField(name) // I prefer to get attributes this way
|
||||
.GetCustomAttributes(false)
|
||||
.OfType<TAttribute>()
|
||||
.SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue