Esempio n. 1
0
        public static T[] GetAttributes <T>(this MemberInfo memberInfo, bool inherit) where T : Attribute
        {
            Ensure.That(memberInfo).Named("memberInfo").IsNotNull();

            T[] returnValue = null;

            if (MemberInfoExtensions.IsAttributeDefined <T>(memberInfo, inherit))
            {
                Object[] attributes = memberInfo.GetCustomAttributes(typeof(T), inherit);
                returnValue = attributes.Cast <T>().ToArray <T>();
            }
            else
            {
                returnValue = new T[0];
            }

            return(returnValue);
        }
Esempio n. 2
0
        public static T[] GetAttributes <T>(this MemberInfo memberInfo) where T : Attribute
        {
            Ensure.That(memberInfo).Named("memberInfo").IsNotNull();

            return(MemberInfoExtensions.GetAttributes <T>(memberInfo, true));
        }