mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 22:06:30 +00:00
4780e8c61c
fix schema migrator for enums
12 lines
336 B
C#
12 lines
336 B
C#
namespace Azaion.Common.Extensions;
|
|
|
|
public static class EnumExtensions
|
|
{
|
|
public static T GetValueOrDefault<T>(this string value, T defaultValue) where T : struct
|
|
{
|
|
if (string.IsNullOrEmpty(value))
|
|
return defaultValue;
|
|
|
|
return Enum.TryParse(value, true, out T result) ? result : defaultValue;
|
|
}
|
|
} |