rabidus-test/Assets/Plugins/QFSW/Quantum Console/Source/Scripts/Parsing/Parsers/EnumParser.cs

20 lines
565 B
C#
Raw Normal View History

2023-08-22 15:41:12 +03:00
using QFSW.QC.Utilities;
using System;
namespace QFSW.QC.Parsers
{
public class EnumParser : PolymorphicCachedQcParser<Enum>
{
public override Enum Parse(string value, Type type)
{
try
{
return (Enum)Enum.Parse(type, value);
}
catch (Exception e)
{
throw new ParserInputException($"Cannot parse '{value}' to the type '{type.GetDisplayName()}'. To see the supported values, use the command `enum-info {type}`", e);
}
}
}
}