Thu Dec 13 20:10:57 CET 2001 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / corlib / System / MonoType.cs
1 // System.MonoType
2 //
3 // Sean MacIsaac (macisaac@ximian.com)
4 //
5 // (C) 2001 Ximian, Inc.
6
7 using System.Reflection;
8 using System.Runtime.CompilerServices;
9
10 namespace System
11 {
12         internal struct MonoTypeInfo {
13                 public string name;
14                 public string name_space;
15                 public Type parent;
16                 public Type etype;
17                 public Type[] interfaces;
18                 public Assembly assembly;
19         }
20
21         internal class MonoType : Type
22         {
23
24                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
25                 private static extern void type_from_obj (MonoType type, Object obj);
26                 
27                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
28                 private static extern void get_type_info (RuntimeTypeHandle type, out MonoTypeInfo info);
29
30                 internal MonoType (Object obj) {
31                         type_from_obj (this, obj);
32                 }
33
34                 public override Type[] GetInterfaces()
35                 {
36                         MonoTypeInfo info;
37                         get_type_info (_impl, out info);
38                         return info.interfaces;
39                 }
40
41                 public override Type GetElementType()
42                 {
43                         MonoTypeInfo info;
44                         get_type_info (_impl, out info);
45                         return info.etype;
46                 }
47
48                 public override Type UnderlyingSystemType {
49                         get {
50                                 MonoTypeInfo info;
51                                 get_type_info (_impl, out info);
52                                 return info.etype;
53                         }
54                 }
55
56                 public override Assembly Assembly {
57                         get {
58                                 MonoTypeInfo info;
59                                 get_type_info (_impl, out info);
60                                 return info.assembly;
61                         }
62                 }
63
64                 public override string AssemblyQualifiedName {
65                         get {
66                                 return assQualifiedName ();
67                         }
68                 }
69
70                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
71                 private extern string assQualifiedName();
72
73                 public override Type BaseType {
74                         get {
75                                 MonoTypeInfo info;
76                                 get_type_info (_impl, out info);
77                                 return info.parent;
78                         }
79                 }
80
81                 public override string FullName {
82                         get {
83                                 string str = assQualifiedName ();
84                                 return str.Split(',')[0];
85                         }
86                 }
87
88                 public override bool IsDefined (Type attributeType, bool inherit)
89                 {
90                         return false;
91                 }
92
93                 public override object[] GetCustomAttributes (bool inherit)
94                 {
95                         return null;
96                 }
97
98                 public override object[] GetCustomAttributes (Type attributeType, bool inherit)
99                 {
100                         return null;
101                 }
102
103                 public override MemberTypes MemberType {
104                         get {
105                                 return MemberTypes.All;
106                         }
107                 }
108
109                 public override string Name {
110                         get {
111                                 MonoTypeInfo info;
112                                 get_type_info (_impl, out info);
113                                 return info.name;
114                         }
115                 }
116
117                 public override string Namespace {
118                         get {
119                                 MonoTypeInfo info;
120                                 get_type_info (_impl, out info);
121                                 return info.name_space;
122                         }
123                 }
124
125                 public override Module Module {
126                         get {
127                                 return null;
128                         }
129                 }
130
131                 public override Type ReflectedType {
132                         get {
133                                 return null;
134                         }
135                 }
136
137                 public override RuntimeTypeHandle TypeHandle {
138                         get {
139                                 return _impl;
140                         }
141                 }
142         }
143 }