增强了实例工程的抽象逻辑

This commit is contained in:
fengjiayi
2024-10-07 15:15:18 +08:00
parent 7a9f7b7bf3
commit 878b1c5893
39 changed files with 1361 additions and 826 deletions

View File

@@ -8,6 +8,16 @@ namespace Serein.Library.Utils
{
public static class EnumHelper
{
public static bool TryConvertEnum<T>(this string value, out T result) where T : struct, Enum
{
if (!string.IsNullOrEmpty(value) && Enum.TryParse(value, true, out T tempResult) && Enum.IsDefined(typeof(T), tempResult))
{
result = tempResult;
return true;
}
result = default;
return false;
}
public static TResult GetBoundValue<TEnum, TResult>(TEnum enumValue, Func<BindValueAttribute, object> valueSelector)
where TEnum : Enum
{