System.Runtime.InteropServices.FieldOffsetAttribute.GetCustomAttribute C# (CSharp) Method

GetCustomAttribute() static private method

static private GetCustomAttribute ( RuntimeFieldInfo field ) : Attribute
field RuntimeFieldInfo
return Attribute
        internal static Attribute GetCustomAttribute(RuntimeFieldInfo field) 
        { 
            int fieldOffset;

            if (field.DeclaringType != null && 
                field.Module.MetadataImport.GetFieldOffset(field.DeclaringType.MetadataToken, field.MetadataToken, out fieldOffset))
                return new FieldOffsetAttribute(fieldOffset);            

            return null;
        }

Usage Example

Beispiel #1
0
 internal static bool IsDefined(RuntimeFieldInfo field)
 {
     return(FieldOffsetAttribute.GetCustomAttribute(field) != null);
 }