1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 15:26:00 +02:00

Added 'interface' and 'enum' constraints

This commit is contained in:
Brian Fiete 2020-11-10 05:44:23 -08:00
parent f63b9236d0
commit f41365a58e
8 changed files with 110 additions and 27 deletions

View file

@ -423,7 +423,7 @@ namespace Beefy.utils
}
}
public void Get<T>(StringView name, ref T val) where T : Enum
public void Get<T>(StringView name, ref T val) where T : enum
{
Object obj = Get(name);
if (obj == null)
@ -547,7 +547,7 @@ namespace Beefy.utils
return (bool)aVal;
}
public T GetEnum<T>(String name, T defaultVal = default(T)) where T : Enum
public T GetEnum<T>(String name, T defaultVal = default(T)) where T : enum
{
Object obj = Get(name);
if (obj == null)
@ -566,7 +566,7 @@ namespace Beefy.utils
return defaultVal;
}
public bool GetEnum<T>(String name, ref T val) where T : Enum
public bool GetEnum<T>(String name, ref T val) where T : enum
{
Object obj = Get(name);
if (obj == null)
@ -614,7 +614,7 @@ namespace Beefy.utils
return;
}
public T GetCurEnum<T>(T theDefault = default) where T : Enum
public T GetCurEnum<T>(T theDefault = default) where T : enum
{
Object obj = GetCurrent();

View file

@ -18,7 +18,7 @@ namespace System
((int32)iVal).ToString(strBuffer);
}
public static Result<T> Parse<T>(StringView str, bool ignoreCase = false) where T : Enum
public static Result<T> Parse<T>(StringView str, bool ignoreCase = false) where T : enum
{
var typeInst = (TypeInstance)typeof(T);
for (var field in typeInst.GetFields())