System.Attribute.Attribute.IsDefined C# (CSharp) Method

IsDefined() public static method

public static IsDefined ( MemberInfo element, Type attributeType, bool inherit ) : bool
element System.Reflection.MemberInfo
attributeType Type
inherit bool
return bool
		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);
		}

Same methods

Attribute.Attribute::IsDefined ( Assembly element, Type attributeType ) : bool
Attribute.Attribute::IsDefined ( Assembly element, Type attributeType, bool inherit ) : bool
Attribute.Attribute::IsDefined ( MemberInfo element, Type attributeType ) : bool
Attribute.Attribute::IsDefined ( Module element, Type attributeType ) : bool
Attribute.Attribute::IsDefined ( Module element, Type attributeType, bool inherit ) : bool
Attribute.Attribute::IsDefined ( ParameterInfo element, Type attributeType ) : bool
Attribute.Attribute::IsDefined ( ParameterInfo element, Type attributeType, bool inherit ) : bool