Revert patch
[mono.git] / mcs / class / corlib / System.Reflection / MonoProperty.cs
1
2
3 //
4 // System.Reflection/MonoProperty.cs
5 // The class used to represent Properties from the mono runtime.
6 //
7 // Author:
8 //   Paolo Molaro (lupus@ximian.com)
9 //
10 // (C) 2001 Ximian, Inc.  http://www.ximian.com
11 //
12
13 using System;
14 using System.Globalization;
15 using System.Runtime.CompilerServices;
16 using System.Runtime.InteropServices;
17
18 namespace System.Reflection {
19         
20         internal struct MonoPropertyInfo {
21                 public Type parent;
22                 public String name;
23                 public MethodInfo get_method;
24                 public MethodInfo set_method;
25                 public PropertyAttributes attrs;
26                 
27                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
28                 internal static extern void get_property_info (MonoProperty prop, out MonoPropertyInfo info);
29         }
30
31         internal class MonoProperty : PropertyInfo {
32                 internal IntPtr klass;
33                 internal IntPtr prop;
34                 
35                 public override PropertyAttributes Attributes {
36                         get {
37                                 MonoPropertyInfo info;
38                                 MonoPropertyInfo.get_property_info (this, out info);
39                                 return info.attrs;
40                         }
41                 }
42                 public override bool CanRead {
43                         get {
44                                 MonoPropertyInfo info;
45                                 MonoPropertyInfo.get_property_info (this, out info);
46                                 return (info.get_method != null);
47                         }
48                 }
49                 public override bool CanWrite {
50                         get {
51                                 MonoPropertyInfo info;
52                                 MonoPropertyInfo.get_property_info (this, out info);
53                                 return (info.set_method != null);
54                         }
55                 }
56
57                 [MonoTODO]
58                 public override Type PropertyType {
59                         get {
60                                 MonoPropertyInfo info;
61                                 MonoPropertyInfo.get_property_info (this, out info);
62                                 
63                                 if (info.get_method != null) {
64                                         return info.get_method.ReturnType;
65                                 } else {
66                                         // FIXME: take the last param to set_method
67                                         return null;
68                                 }
69                         }
70                 }
71                 public override Type ReflectedType {
72                         get {
73                                 MonoPropertyInfo info;
74                                 MonoPropertyInfo.get_property_info (this, out info);
75                                 return info.parent;
76                         }
77                 }
78                 public override Type DeclaringType {
79                         get {
80                                 MonoPropertyInfo info;
81                                 MonoPropertyInfo.get_property_info (this, out info);
82                                 return info.parent;
83                         }
84                 }
85                 public override string Name {
86                         get {
87                                 MonoPropertyInfo info;
88                                 MonoPropertyInfo.get_property_info (this, out info);
89                                 return info.name;
90                         }
91                 }
92
93                 [MonoTODO]
94                 public override MethodInfo[] GetAccessors( bool nonPublic) {
95                         // FIXME: check nonPublic
96                         MonoPropertyInfo info;
97                         int n = 0;
98                         MonoPropertyInfo.get_property_info (this, out info);
99                         if (info.set_method != null)
100                                 n++;
101                         if (info.get_method != null)
102                                 n++;
103                         MethodInfo[] res = new MethodInfo [n];
104                         n = 0;
105                         if (info.set_method != null)
106                                 res [n++] = info.set_method;
107                         if (info.get_method != null)
108                                 res [n++] = info.get_method;
109                         return res;
110                 }
111
112                 [MonoTODO]
113                 public override MethodInfo GetGetMethod( bool nonPublic) {
114                         // FIXME: check nonPublic
115                         MonoPropertyInfo info;
116                         MonoPropertyInfo.get_property_info (this, out info);
117                         return info.get_method;
118                 }
119                 public override ParameterInfo[] GetIndexParameters() {
120                         MonoPropertyInfo info;
121                         MonoPropertyInfo.get_property_info (this, out info);
122                         if (info.get_method != null)
123                                 return info.get_method.GetParameters ();
124                         return new ParameterInfo [0];
125                 }
126                 public override MethodInfo GetSetMethod( bool nonPublic) {
127                         // FIXME: check nonPublic
128                         MonoPropertyInfo info;
129                         MonoPropertyInfo.get_property_info (this, out info);
130                         return info.set_method;
131                 }
132                 public override bool IsDefined (Type attribute_type, bool inherit) {
133                         return false;
134                 }
135
136                 public override object[] GetCustomAttributes( bool inherit) {
137                         return null;
138                 }
139                 public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
140                         return null;
141                 }
142                 public override object GetValue( object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
143                         return null;
144                 }
145                 public override void SetValue( object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
146                 }
147         }
148 }
149