using System;
namespace UniGLTF.Utils
{
///
/// CachedEnumType に対するインターフェース。
/// 非 Generic class
///
public static class CachedEnum
{
public static T Parse(string name, bool ignoreCase = false) where T : struct, Enum
{
if (ignoreCase)
{
return CachedEnumType.IgnoreCaseMap[name];
}
else
{
return CachedEnumType.Map[name];
}
}
public static T ParseOrDefault(string name, bool ignoreCase = false, T defaultValue = default)
where T : struct, Enum
{
try
{
return Parse(name, ignoreCase: ignoreCase);
}
catch (System.Collections.Generic.KeyNotFoundException)
{
return defaultValue;
}
}
public static T[] GetValues() where T : struct, Enum
{
return CachedEnumType.Values;
}
}
}