private void GetOneTimeFlags()
{
Type declaringType = DeclaringType;
// first take care of all the NO_INVOKE cases
if (declaringType != null && declaringType.ContainsGenericParameters)
{
m_invocationFlags |= INVOCATION_FLAGS_NO_INVOKE;
}
else if (Module.Assembly.GetType() == typeof(AssemblyBuilder))
{
AssemblyBuilder ab = Module.Assembly as AssemblyBuilder;
if (ab.m_assemblyData.m_access == AssemblyBuilderAccess.Save)
m_invocationFlags |= INVOCATION_FLAGS_NO_INVOKE;
}
if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
{
m_invocationFlags |= INVOCATION_FLAGS_NO_INVOKE;
}
// this should be an usable field, determine the other flags
else
{
if ((m_fieldAttributes & FieldAttributes.InitOnly) !=(FieldAttributes)0)
m_invocationFlags |= INVOCATION_FLAGS_SPECIAL_FIELD;
if ((m_fieldAttributes & FieldAttributes.HasFieldRVA) !=(FieldAttributes)0)
m_invocationFlags |= INVOCATION_FLAGS_SPECIAL_FIELD;
if (((m_fieldAttributes & FieldAttributes.FieldAccessMask) != FieldAttributes.Public) || (declaringType != null && !declaringType.IsVisible))
m_invocationFlags |= INVOCATION_FLAGS_NEED_SECURITY;
// find out if the field type is one of the following: Primitive, Enum or Pointer
Type fieldType = FieldType;
if (fieldType.IsPointer || fieldType.IsEnum || fieldType.IsPrimitive)
m_invocationFlags |= INVOCATION_FLAGS_FIELD_SPECIAL_CAST;
}
// must be last to avoid threading problems
m_invocationFlags |= INVOCATION_FLAGS_INITIALIZED;
}