Thu Feb 14 18:55:52 CET 2002 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / corlib / System.Reflection.Emit / FieldBuilder.cs
1
2
3 //
4 // System.Reflection.Emit/FieldBuilder.cs
5 //
6 // Author:
7 //   Paolo Molaro (lupus@ximian.com)
8 //
9 // (C) 2001 Ximian, Inc.  http://www.ximian.com
10 //
11
12 using System;
13 using System.Reflection;
14 using System.Reflection.Emit;
15 using System.Globalization;
16 using System.Runtime.CompilerServices;
17
18 namespace System.Reflection.Emit {
19         public sealed class FieldBuilder : FieldInfo {
20                 private FieldAttributes attrs;
21                 private Type type;
22                 private String name;
23                 private object def_value;
24                 private int offset;
25                 private int table_idx;
26                 internal TypeBuilder typeb;
27                 private byte[] rva_data;
28
29                 internal FieldBuilder (TypeBuilder tb, string fieldName, Type type, FieldAttributes attributes) {
30                         attrs = attributes;
31                         name = fieldName;
32                         this.type = type;
33                         offset = -1;
34                         typeb = tb;
35                         table_idx = tb.get_next_table_index (0x04, true);
36                 }
37
38                 public override FieldAttributes Attributes {
39                         get {return attrs;}
40                 }
41                 public override Type DeclaringType {
42                         get {return typeb;}
43                 }
44                 public override RuntimeFieldHandle FieldHandle {
45                         get {return new RuntimeFieldHandle();}
46                 }
47                 public override Type FieldType {
48                         get {return type;}
49                 }
50                 public override string Name {
51                         get {return name;}
52                 }
53                 public override Type ReflectedType {
54                         get {return null;}
55                 }
56
57                 public override object[] GetCustomAttributes(bool inherit) {
58                         return null;
59                 }
60                 public override object[] GetCustomAttributes(Type attributeType, bool inherit) {
61                         return null;
62                 }
63                 public FieldToken GetToken() {
64                         return new FieldToken (0x04000000 | table_idx);
65                 }
66                 public override object GetValue(object obj) {
67                         return null;
68                 }
69                 public override bool IsDefined( Type attributeType, bool inherit) {
70                         return false;
71                 }
72                 internal void SetRVAData (byte[] data) {
73                         rva_data = (byte[])data.Clone ();
74                 }
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;
79                 }
80                 public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
81                 }
82                 public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
83                 }
84                 public void SetMarshal( UnmanagedMarshal unmanagedMarshal) {
85                 }
86                 public void SetOffset( int iOffset) {
87                         offset = iOffset;
88                 }
89                 public override void SetValue( object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture) {
90                 }
91
92         }
93 }
94