mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-06-16 10:44:32 +02:00
31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
|
namespace MLEM.Misc {
|
|
/// <summary>
|
|
/// A helper class that allows easier usage of <see cref="Enum"/> values.
|
|
/// </summary>
|
|
public static class EnumHelper {
|
|
|
|
/// <summary>
|
|
/// All values of the <see cref="Buttons"/> enum.
|
|
/// </summary>
|
|
public static readonly Buttons[] Buttons = EnumHelper.GetValues<Buttons>();
|
|
/// <summary>
|
|
/// All values of the <see cref="Keys"/> enum.
|
|
/// </summary>
|
|
public static readonly Keys[] Keys = EnumHelper.GetValues<Keys>();
|
|
|
|
/// <summary>
|
|
/// Returns an array containing all of the values of the given enum type.
|
|
/// Note that this method is a version-independent equivalent of .NET 5's <c>Enum.GetValues<TEnum></c>.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type whose enum to get</typeparam>
|
|
/// <returns>An enumerable of the values of the enum, in declaration order.</returns>
|
|
public static T[] GetValues<T>() {
|
|
return (T[]) Enum.GetValues(typeof(T));
|
|
}
|
|
|
|
}
|
|
}
|