上传了新的示例工程

This commit is contained in:
fengjiayi
2024-09-27 10:30:19 +08:00
parent 54c35ce445
commit f3a90df452
24 changed files with 1062 additions and 127 deletions

View File

@@ -16,6 +16,13 @@ namespace Serein.Library.Utils
return attribute != null ? (TResult)valueSelector(attribute) : default;
}
public static object GetBoundValue(Type enumType,object enumValue, Func<BindValueAttribute, object> valueSelector)
{
var fieldInfo = enumType.GetField(enumValue.ToString());
var attribute = fieldInfo.GetCustomAttribute<BindValueAttribute>();
return attribute != null ? valueSelector(attribute) : default;
}
//public static TResult GetBoundValue<TEnum, TAttribute, TResult>(TEnum enumValue,
// Func<TAttribute, TResult> valueSelector)