mscorlib(4.0.0.0) API with additions
FieldOffsetAttribute.cs
1 using System.Reflection;
2 using System.Security;
3 
5 {
7  [AttributeUsage(AttributeTargets.Field, Inherited = false)]
8  [ComVisible(true)]
9  [__DynamicallyInvokable]
10  public sealed class FieldOffsetAttribute : Attribute
11  {
12  internal int _val;
13 
16  [__DynamicallyInvokable]
17  public int Value
18  {
19  [__DynamicallyInvokable]
20  get
21  {
22  return _val;
23  }
24  }
25 
26  [SecurityCritical]
27  internal static Attribute GetCustomAttribute(RuntimeFieldInfo field)
28  {
29  if (field.DeclaringType != null && field.GetRuntimeModule().MetadataImport.GetFieldOffset(field.DeclaringType.MetadataToken, field.MetadataToken, out int offset))
30  {
31  return new FieldOffsetAttribute(offset);
32  }
33  return null;
34  }
35 
36  [SecurityCritical]
37  internal static bool IsDefined(RuntimeFieldInfo field)
38  {
39  return GetCustomAttribute(field) != null;
40  }
41 
44  [__DynamicallyInvokable]
45  public FieldOffsetAttribute(int offset)
46  {
47  _val = offset;
48  }
49  }
50 }
FieldOffsetAttribute(int offset)
Initializes a new instance of the T:System.Runtime.InteropServices.FieldOffsetAttribute class with th...
Represents the base class for custom attributes.
Definition: Attribute.cs:15
Definition: __Canon.cs:3
int Value
Gets the offset from the beginning of the structure to the beginning of the field.
Indicates the physical position of fields within the unmanaged representation of a class or structure...
AttributeTargets
Specifies the application elements on which it is valid to apply an attribute.