コード例 #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));
        }
コード例 #2
0
 public static TAttr[] AllAttributes <TAttr>(this PropertyInfo pi)
 {
     return(PlatformExtensions.AllAttributes(pi, typeof(TAttr)).Cast <TAttr>().ToArray <TAttr>());
 }
コード例 #3
0
 public static TAttr[] AllAttributes <TAttr>(this FieldInfo fi)
 {
     return(PlatformExtensions.AllAttributes(fi, typeof(TAttr)).Cast <TAttr>().ToArray <TAttr>());
 }
コード例 #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)));
        }
コード例 #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))));
 }