准备区分节点、参数、返回值的连接,做个备份

This commit is contained in:
fengjiayi
2024-10-23 19:22:27 +08:00
parent a495a34413
commit 0666f0b2c1
36 changed files with 1497 additions and 756 deletions

View File

@@ -26,8 +26,21 @@ namespace Serein.Library.Utils
result = default;
return false;
}
/// <summary>
/// 将字符串的字面量枚举值,转为对应的枚举值
/// </summary>
/// <typeparam name="TEnum">枚举</typeparam>
/// <param name="value">枚举字面量</param>
/// <returns>转换后的枚举值</returns>
public static TEnum ConvertEnum<TEnum>(this string value) where TEnum : struct, Enum
{
if (!string.IsNullOrEmpty(value) && Enum.TryParse(value, true, out TEnum tempResult) && Enum.IsDefined(typeof(TEnum), tempResult))
{
return tempResult;
}
throw new NotImplementedException($"枚举值转换失败value{value}to enum {typeof(TEnum).FullName}");
}
/// <summary>
/// 从枚举值的 BindValueAttribute 特性中 获取绑定的参数(用于绑定了某些内容的枚举值)