System.Reflection.CustomAttribute.IsDefined C# (CSharp) Method

IsDefined() static private method

static private IsDefined ( RuntimeType type, RuntimeType caType, bool inherit ) : bool
type RuntimeType
caType RuntimeType
inherit bool
return bool
        internal static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
        {
            ASSERT.PRECONDITION(type != null);

            if (type.GetElementType() != null) 
                return false;

            if (PseudoCustomAttribute.IsDefined(type, caType))
                return true;

            if (IsCustomAttributeDefined(type.Module, type.MetadataToken, caType))
                return true;

            if (!inherit)
                return false;

            type = type.BaseType as RuntimeType;

            while (type != null)
            {
                if (IsCustomAttributeDefined(type.Module, type.MetadataToken, caType, inherit))
                    return true;

                type = type.BaseType as RuntimeType;
            }

            return false;
        }

Same methods

CustomAttribute::IsDefined ( Assembly assembly, RuntimeType caType ) : bool
CustomAttribute::IsDefined ( Module module, RuntimeType caType ) : bool
CustomAttribute::IsDefined ( ParameterInfo parameter, RuntimeType caType ) : bool
CustomAttribute::IsDefined ( RuntimeConstructorInfo ctor, RuntimeType caType ) : bool
CustomAttribute::IsDefined ( RuntimeEventInfo e, RuntimeType caType ) : bool
CustomAttribute::IsDefined ( RuntimeFieldInfo field, RuntimeType caType ) : bool
CustomAttribute::IsDefined ( RuntimeMethodInfo method, RuntimeType caType, bool inherit ) : bool
CustomAttribute::IsDefined ( RuntimePropertyInfo property, RuntimeType caType ) : bool

Usage Example

Esempio n. 1
0
 public override bool IsDefined(Type attributeType, bool inherit)
 {
     return(CustomAttribute.IsDefined(this, attributeType, inherit));
 }