1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Added GetCurEnum

This commit is contained in:
Brian Fiete 2020-04-02 08:57:15 -07:00
parent bb59aa3162
commit 79acc766fd

View file

@ -589,6 +589,23 @@ namespace Beefy.utils
return;
}
public T GetCurEnum<T>(T theDefault = default) where T : Enum
{
Object obj = GetCurrent();
Result<T> result;
if (let str = obj as String)
result = Enum.Parse<T>(str);
else if (obj is StringView)
result = Enum.Parse<T>((StringView)obj);
else
return theDefault;
if (result case .Ok(var val))
return val;
return theDefault;
}
public int32 GetCurInt(int32 theDefault = 0)
{
Object aVal = GetCurrent();