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

IsDefined() static private method

static private IsDefined ( RuntimeFieldInfo field, Type caType ) : bool
field RuntimeFieldInfo
caType System.Type
return bool
        internal static bool IsDefined(RuntimeFieldInfo field, Type caType) 
        {
            bool all = caType == typeof(object) || caType == typeof(Attribute);
            if (!all && s_pca[caType] == null)
                return false;

            if (all || caType == typeof(MarshalAsAttribute)) 
            { 
                if (MarshalAsAttribute.IsDefined(field)) return true;
            }
            if (all || caType == typeof(FieldOffsetAttribute)) 
            { 
                if (FieldOffsetAttribute.IsDefined(field)) return true;
            }
            if (all || caType == typeof(NonSerializedAttribute)) 
            { 
                if (NonSerializedAttribute.IsDefined(field)) 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 ( RuntimeConstructorInfo ctor, Type caType ) : bool
PseudoCustomAttribute::IsDefined ( RuntimeEventInfo e, 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