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

IsDefined() static private method

static private IsDefined ( RuntimeConstructorInfo ctor, Type caType ) : bool
ctor RuntimeConstructorInfo
caType System.Type
return bool
        internal static bool IsDefined(RuntimeConstructorInfo ctor, Type caType) 
        {
            bool all = caType == typeof(object) || caType == typeof(Attribute);

            if (!all && s_pca[caType] == null)
                return false;

            if (all || IsSecurityAttribute(caType))
            {
                int count;

                if (GetCustomAttributes(ctor, caType, true, out count).Length != 0)
                    return true;
            }

            return false;
        }

Same methods

PseudoCustomAttribute::IsDefined ( Assembly assembly, Type caType ) : bool
PseudoCustomAttribute::IsDefined ( Module module, Type caType ) : bool
PseudoCustomAttribute::IsDefined ( ParameterInfo parameter, Type caType ) : bool
PseudoCustomAttribute::IsDefined ( RuntimeEventInfo e, Type caType ) : bool
PseudoCustomAttribute::IsDefined ( RuntimeFieldInfo field, Type caType ) : bool
PseudoCustomAttribute::IsDefined ( RuntimeMethodInfo method, Type caType ) : bool
PseudoCustomAttribute::IsDefined ( RuntimePropertyInfo property, Type caType ) : bool
PseudoCustomAttribute::IsDefined ( RuntimeType type, Type caType ) : bool

Usage Example

 internal static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
 {
     if (type.GetElementType() != null)
     {
         return(false);
     }
     if (PseudoCustomAttribute.IsDefined(type, caType))
     {
         return(true);
     }
     if (CustomAttribute.IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType))
     {
         return(true);
     }
     if (!inherit)
     {
         return(false);
     }
     type = (type.BaseType as RuntimeType);
     while (type != null)
     {
         if (CustomAttribute.IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType, 0, inherit))
         {
             return(true);
         }
         type = (type.BaseType as RuntimeType);
     }
     return(false);
 }
All Usage Examples Of System.Reflection.PseudoCustomAttribute::IsDefined