Exemplo n.º 1
0
        public static T GetCustomAttribute <T>(this _MemberInfo member, bool inherit = true)
        {
            T   t     = default(T);
            var attrs = member.GetCustomAttributes(typeof(T), inherit);

            if (attrs.Length > 0)
            {
                t = (T)attrs[0];
            }
            return(t);
        }
Exemplo n.º 2
0
        public static IEnumerable <T> GetCustomAttributes <T>(this _MemberInfo type, bool inherit)
        {
            IList <T> list = new List <T>();

            object[] array = type.GetCustomAttributes(typeof(T), inherit);
            if (array != null)
            {
                foreach (var a in array)
                {
                    list.Add((T)a);
                }
            }
            return(list);
        }