2003-02-28 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / corlib / System.Reflection.Emit / PropertyBuilder.cs
1
2 //
3 // System.Reflection.Emit/PropertyBuilder.cs
4 //
5 // Author:
6 //   Paolo Molaro (lupus@ximian.com)
7 //
8 // (C) 2001 Ximian, Inc.  http://www.ximian.com
9 //
10
11 using System;
12 using System.Reflection;
13 using System.Reflection.Emit;
14 using System.Globalization;
15 using System.Runtime.CompilerServices;
16
17 namespace System.Reflection.Emit {
18         public sealed class PropertyBuilder : PropertyInfo {
19                 private PropertyAttributes attrs;
20                 private string name;
21                 private Type type;
22                 private Type[] parameters;
23                 private CustomAttributeBuilder[] cattrs;
24                 private object def_value;
25                 private MethodBuilder set_method;
26                 private MethodBuilder get_method;
27                 private int table_idx = 0;
28                 internal TypeBuilder typeb;
29                 
30                 internal PropertyBuilder (TypeBuilder tb, string name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) {
31                         this.name = name;
32                         this.attrs = attributes;
33                         this.type = returnType;
34                         if (parameterTypes != null) {
35                                 this.parameters = new Type [parameterTypes.Length];
36                                 System.Array.Copy (parameterTypes, this.parameters, this.parameters.Length);
37                         }
38                         typeb = tb;
39                         table_idx = tb.get_next_table_index (this, 0x17, true);
40                 }
41
42                 public override PropertyAttributes Attributes {
43                         get {return attrs;}
44                 }
45                 public override bool CanRead {
46                         get {return get_method != null;}
47                 }
48                 public override bool CanWrite {
49                         get {return set_method != null;}
50                 }
51                 public override Type DeclaringType {
52                         get {return typeb;}
53                 }
54                 public override string Name {
55                         get {return name;}
56                 }
57                 public PropertyToken PropertyToken {
58                         get {return new PropertyToken ();}
59                 }
60                 public override Type PropertyType {
61                         get {return type;}
62                 }
63                 public override Type ReflectedType {
64                         get {return typeb;}
65                 }
66                 public void AddOtherMethod( MethodBuilder mdBuilder) {
67                 }
68                 public override MethodInfo[] GetAccessors( bool nonPublic) {
69                         return null;
70                 }
71                 public override object[] GetCustomAttributes(bool inherit) {
72                         return null;
73                 }
74                 public override object[] GetCustomAttributes(Type attributeType, bool inherit) {
75                         return null;
76                 }
77                 public override MethodInfo GetGetMethod( bool nonPublic) {
78                         return get_method;
79                 }
80                 public override ParameterInfo[] GetIndexParameters() {
81                         return null;
82                 }
83                 public override MethodInfo GetSetMethod( bool nonPublic) {
84                         return set_method;
85                 }
86                 public override object GetValue(object obj, object[] index) {
87                         return null;
88                 }
89                 public override object GetValue( object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
90                         return null;
91                 }
92                 public override bool IsDefined( Type attributeType, bool inherit) {
93                         return false;
94                 }
95                 public void SetConstant( object defaultValue) {
96                         def_value = defaultValue;
97                 }
98                 public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
99                         if (cattrs != null) {
100                                 CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
101                                 cattrs.CopyTo (new_array, 0);
102                                 new_array [cattrs.Length] = customBuilder;
103                                 cattrs = new_array;
104                         } else {
105                                 cattrs = new CustomAttributeBuilder [1];
106                                 cattrs [0] = customBuilder;
107                         }
108                 }
109                 public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
110                         SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
111                 }
112                 public void SetGetMethod( MethodBuilder mdBuilder) {
113                         get_method = mdBuilder;
114                 }
115                 public void SetSetMethod( MethodBuilder mdBuilder) {
116                         set_method = mdBuilder;
117                 }
118                 public override void SetValue( object obj, object value, object[] index) {
119                 }
120                 public override void SetValue( object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
121                 }
122         }
123 }
124