mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-04 23:36:35 +08:00
优化了示例工程
This commit is contained in:
@@ -24,16 +24,16 @@ namespace Serein.Library.Utils
|
||||
return attribute != null ? valueSelector(attribute) : default;
|
||||
}
|
||||
|
||||
//public static TResult GetBoundValue<TEnum, TAttribute, TResult>(TEnum enumValue,
|
||||
// Func<TAttribute, TResult> valueSelector)
|
||||
// where TEnum : Enum
|
||||
// where TAttribute : Attribute
|
||||
//{
|
||||
// var fieldInfo = typeof(TEnum).GetField(enumValue.ToString());
|
||||
// var attribute = fieldInfo.GetCustomAttribute<TAttribute>();
|
||||
public static TResult GetBoundValue<TEnum, TAttribute, TResult>(TEnum enumValue,
|
||||
Func<TAttribute, TResult> valueSelector)
|
||||
where TEnum : Enum
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
var fieldInfo = typeof(TEnum).GetField(enumValue.ToString());
|
||||
var attribute = fieldInfo.GetCustomAttribute<TAttribute>();
|
||||
|
||||
// return attribute != null ? valueSelector(attribute) : default;
|
||||
//}
|
||||
return attribute != null ? valueSelector(attribute) : default;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user