4 // System.Reflection.Emit/FieldBuilder.cs
7 // Paolo Molaro (lupus@ximian.com)
9 // (C) 2001 Ximian, Inc. http://www.ximian.com
13 using System.Reflection;
14 using System.Reflection.Emit;
15 using System.Globalization;
16 using System.Runtime.CompilerServices;
18 namespace System.Reflection.Emit {
19 public sealed class FieldBuilder : FieldInfo {
20 private FieldAttributes attrs;
23 private object def_value;
25 private int table_idx;
26 internal TypeBuilder typeb;
27 private byte[] rva_data;
29 internal FieldBuilder (TypeBuilder tb, string fieldName, Type type, FieldAttributes attributes) {
35 table_idx = tb.get_next_table_index (0x04, true);
38 public override FieldAttributes Attributes {
41 public override Type DeclaringType {
44 public override RuntimeFieldHandle FieldHandle {
45 get {return new RuntimeFieldHandle();}
47 public override Type FieldType {
50 public override string Name {
53 public override Type ReflectedType {
57 public override object[] GetCustomAttributes(bool inherit) {
60 public override object[] GetCustomAttributes(Type attributeType, bool inherit) {
63 public FieldToken GetToken() {
64 return new FieldToken (0x04000000 | table_idx);
66 public override object GetValue(object obj) {
69 public override bool IsDefined( Type attributeType, bool inherit) {
72 internal void SetRVAData (byte[] data) {
73 rva_data = (byte[])data.Clone ();
75 public void SetConstant( object defaultValue) {
76 /*if (defaultValue.GetType() != type)
77 throw new ArgumentException ("Constant doesn't match field type");*/
78 def_value = defaultValue;
80 public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
82 public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
84 public void SetMarshal( UnmanagedMarshal unmanagedMarshal) {
86 public void SetOffset( int iOffset) {
89 public override void SetValue( object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture) {