2019-10-10 00:52:42 -04:00
|
|
|
namespace GitHub.Runner.Common.Util
|
|
|
|
|
{
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
public static class EnumUtil
|
|
|
|
|
{
|
2023-06-02 21:47:59 +02:00
|
|
|
public static T? TryParse<T>(string value) where T : struct
|
2019-10-10 00:52:42 -04:00
|
|
|
{
|
|
|
|
|
T val;
|
|
|
|
|
if (Enum.TryParse(value ?? string.Empty, ignoreCase: true, result: out val))
|
|
|
|
|
{
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|