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));
        }

댓글

이 블로그의 인기 게시물

Oracle NLS_DATE_FORMAT 변경

Stop console process using Ctrl+C.

Alternative to IValueConvert, QuickConverter