Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ IsDefined() [8/8]

static bool System.Attribute.IsDefined ( ParameterInfo element,
Type attributeType,
bool inherit )
inlinestaticinherited

Definition at line 489 of file Attribute.cs.

490 {
491 if (element == null)
492 {
493 throw new ArgumentNullException("element");
494 }
495 if (attributeType == null)
496 {
497 throw new ArgumentNullException("attributeType");
498 }
499 if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
500 {
501 throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass);
502 }
503 MemberInfo member = element.Member;
504 return member.MemberType switch
505 {
506 MemberTypes.Method => InternalParamIsDefined(element, attributeType, inherit),
507 MemberTypes.Constructor => element.IsDefined(attributeType, inherit: false),
508 MemberTypes.Property => element.IsDefined(attributeType, inherit: false),
509 _ => throw new ArgumentException(SR.Argument_InvalidParamInfo),
510 };
511 }
static bool IsDefined(MemberInfo element, Type attributeType)
Definition Attribute.cs:384
static bool InternalParamIsDefined(ParameterInfo param, Type type, bool inherit)
Definition Attribute.cs:244
virtual bool IsDefined(Type attributeType, bool inherit)

References System.SR.Argument_InvalidParamInfo, System.SR.Argument_MustHaveAttributeBaseClass, System.Attribute.InternalParamIsDefined(), System.Reflection.ParameterInfo.IsDefined(), System.Type.IsSubclassOf(), and System.Reflection.ParameterInfo.Member.