mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-04-21 13:49:42 +00:00
27 lines
814 B
C#
27 lines
814 B
C#
namespace SabreTools.Metadata.DatItems
|
|
{
|
|
public static class Extensions
|
|
{
|
|
#region String to Enum
|
|
|
|
/// <summary>
|
|
/// Get the enum value for an input string, if possible
|
|
/// </summary>
|
|
/// <param name="value">String value to parse/param>
|
|
/// <returns>Enum value representing the input, default on error</returns>
|
|
public static MachineType AsMachineType(this string? value)
|
|
{
|
|
return value?.ToLowerInvariant() switch
|
|
{
|
|
"none" => MachineType.None,
|
|
"bios" => MachineType.Bios,
|
|
"device" or "dev" => MachineType.Device,
|
|
"mechanical" or "mech" => MachineType.Mechanical,
|
|
_ => MachineType.None,
|
|
};
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|