Enum and Attribute
public static IEnumerable<T1> FilterEnumerables<T1, T2>(Predicate<T2> predicate)
where T1 : struct, IConvertible //Enum
where T2 : Attribute //Attribute
{
return typeof (T1)
.GetFields()
.Where(f => f.GetCustomAttributes(typeof (T2)).Any()
&& predicate(f.GetCustomAttribute<t2>()))
.Select(f => (T1) Enum.Parse(typeof (T1), f.Name));
}
댓글
댓글 쓰기