IsDefined() статический приватный Метод

static private IsDefined ( ICustomAttributeProvider obj, Type attributeType, bool inherit ) : bool
obj ICustomAttributeProvider
attributeType Type
inherit bool
Результат bool
Пример #1
0
        internal static bool IsDefined(ICustomAttributeProvider obj, Type attributeType, bool inherit)
        {
            if (attributeType == null)
            {
                throw new ArgumentNullException("attributeType");
            }
            if (MonoCustomAttrs.IsUserCattrProvider(obj))
            {
                return(obj.IsDefined(attributeType, inherit));
            }
            if (MonoCustomAttrs.IsDefinedInternal(obj, attributeType))
            {
                return(true);
            }
            object[] pseudoCustomAttributes = MonoCustomAttrs.GetPseudoCustomAttributes(obj, attributeType);
            if (pseudoCustomAttributes != null)
            {
                for (int i = 0; i < pseudoCustomAttributes.Length; i++)
                {
                    if (attributeType.IsAssignableFrom(pseudoCustomAttributes[i].GetType()))
                    {
                        return(true);
                    }
                }
            }
            ICustomAttributeProvider @base;

            return(inherit && (@base = MonoCustomAttrs.GetBase(obj)) != null && MonoCustomAttrs.IsDefined(@base, attributeType, inherit));
        }
Пример #2
0
        public static bool IsDefined(MemberInfo element, Type attributeType, bool inherit)
        {
            CheckParameters(element, attributeType);

            MemberTypes mtype = element.MemberType;

            if (mtype != MemberTypes.Constructor && mtype != MemberTypes.Event &&
                mtype != MemberTypes.Field && mtype != MemberTypes.Method &&
                mtype != MemberTypes.Property && mtype != MemberTypes.TypeInfo &&
                mtype != MemberTypes.NestedType)
            {
                throw new NotSupportedException(Locale.GetText(
                                                    "Element is not a constructor, method, property, event, type or field."));
            }
#if NET_2_0
            // MS ignores the inherit param in PropertyInfo's ICustomAttributeProvider
            // implementation, but not in the Attributes, so directly get the attributes
            // from MonoCustomAttrs instead of going throught the PropertyInfo's
            // ICustomAttributeProvider
            if (mtype == MemberTypes.Property)
            {
                return(MonoCustomAttrs.IsDefined(element, attributeType, inherit));
            }
#endif
            return(((MemberInfo)element).IsDefined(attributeType, inherit));
        }
Пример #3
0
        internal static bool IsDefined(ICustomAttributeProvider element, Type attributeType, bool inherit)
        {
            if (attributeType == null)
            {
                throw new ArgumentNullException(nameof(attributeType));
            }
            if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
            {
                throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass + " " + attributeType.FullName);
            }

            return(MonoCustomAttrs.IsDefined(element, attributeType, inherit));
        }
Пример #4
0
 public override bool IsDefined(Type attributeType, bool inherit)
 {
     return(MonoCustomAttrs.IsDefined(this, attributeType, inherit));
 }
Пример #5
0
 static bool InternalIsDefined(PropertyInfo element, Type attributeType, bool inherit)
 {
     return(MonoCustomAttrs.IsDefined(element, attributeType, inherit));
 }
Пример #6
0
 public static bool IsDefined(ParameterInfo element, Type attributeType, bool inherit) => MonoCustomAttrs.IsDefined(element, attributeType, inherit);
Пример #7
0
 public static bool IsDefined(ParameterInfo element, Type attributeType) => MonoCustomAttrs.IsDefined(element, attributeType, true);
Пример #8
0
 public static bool IsDefined(Module element, Type attributeType, bool inherit) => MonoCustomAttrs.IsDefined(element, attributeType, inherit);
Пример #9
0
 public static bool IsDefined(Module element, Type attributeType) => MonoCustomAttrs.IsDefined(element, attributeType, true);