Esempio n. 1
0
        public static object[] AllAttributes(this MemberInfo memberInfo, Type attrType)
        {
            PropertyInfo propertyInfo = memberInfo as PropertyInfo;

            if (propertyInfo != (PropertyInfo)null)
            {
                return(PlatformExtensions.AllAttributes(propertyInfo, attrType));
            }
            return(memberInfo.GetCustomAttributes(attrType, true));
        }
Esempio n. 2
0
 public static TAttr[] AllAttributes <TAttr>(this PropertyInfo pi)
 {
     return(PlatformExtensions.AllAttributes(pi, typeof(TAttr)).Cast <TAttr>().ToArray <TAttr>());
 }
Esempio n. 3
0
 public static TAttr[] AllAttributes <TAttr>(this FieldInfo fi)
 {
     return(PlatformExtensions.AllAttributes(fi, typeof(TAttr)).Cast <TAttr>().ToArray <TAttr>());
 }
Esempio n. 4
0
        public static bool HasAttributeNamed(this FieldInfo fi, string name)
        {
            string normalizedAttr = name.Replace("Attribute", "").ToLower();

            return(((IEnumerable <object>)PlatformExtensions.AllAttributes(fi)).Any <object>((Func <object, bool>)(x => x.GetType().Name.Replace("Attribute", "").ToLower() == normalizedAttr)));
        }
Esempio n. 5
0
 public static bool HasAttribute <T>(this FieldInfo fi)
 {
     return(((IEnumerable <object>)PlatformExtensions.AllAttributes(fi)).Any <object>((Func <object, bool>)(x => x.GetType() == typeof(T))));
 }