mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2025-12-14 02:23:32 +08:00
Added CruiseAssist and AutoPilot
This commit is contained in:
17
AutoPilot/Commons/EnumUtils.cs
Normal file
17
AutoPilot/Commons/EnumUtils.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace AutoPilot.Commons;
|
||||
|
||||
internal static class EnumUtils
|
||||
{
|
||||
public static bool TryParse<TEnum>(string value, out TEnum result) where TEnum : struct
|
||||
{
|
||||
if (value == null || !Enum.IsDefined(typeof(TEnum), value))
|
||||
{
|
||||
result = (TEnum)Enum.GetValues(typeof(TEnum)).GetValue(0);
|
||||
return false;
|
||||
}
|
||||
result = (TEnum)Enum.Parse(typeof(TEnum), value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user