Remove Exts.Enum<T>

This functionality is now built in. We can rely on the built in functions rather than a custom class.
This commit is contained in:
RoosterDragon
2025-11-20 20:09:13 +00:00
committed by Gustas Kažukauskas
parent 00cd438190
commit e652f95be9
6 changed files with 20 additions and 46 deletions

View File

@@ -676,27 +676,4 @@ namespace OpenRA
public ReadOnlySpan<char> Current { get; private set; }
}
public static class Enum<T>
{
public static T Parse(string s) { return (T)Enum.Parse(typeof(T), s); }
public static T[] GetValues() { return (T[])Enum.GetValues(typeof(T)); }
public static bool TryParse(string s, bool ignoreCase, out T value)
{
// The string may be a comma delimited list of values
var names = ignoreCase ? Enum.GetNames(typeof(T)).Select(x => x.ToLowerInvariant()) : Enum.GetNames(typeof(T));
var values = ignoreCase ? s.Split(',').Select(x => x.Trim().ToLowerInvariant()) : s.Split(',').Select(x => x.Trim());
if (values.Any(x => !names.Contains(x)))
{
value = default;
return false;
}
value = (T)Enum.Parse(typeof(T), s, ignoreCase);
return true;
}
}
}