IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
TypeInfo.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2012 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24using System.Collections.Generic;
25
26namespace IKVM.Reflection
27{
28
29 internal abstract class TypeInfo : Type, IReflectableType
30 {
31
32
33 const BindingFlags Flags = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
34
38 internal TypeInfo()
39 {
40
41 }
42
47 internal TypeInfo(Type underlyingType) :
48 base(underlyingType)
49 {
50
51 }
52
57 internal TypeInfo(byte sigElementType) :
58 base(sigElementType)
59 {
60
61 }
62
63 public IEnumerable<ConstructorInfo> DeclaredConstructors
64 {
65 get { return GetConstructors(Flags); }
66 }
67
68 public IEnumerable<EventInfo> DeclaredEvents
69 {
70 get { return GetEvents(Flags); }
71 }
72
73 public IEnumerable<FieldInfo> DeclaredFields
74 {
75 get { return GetFields(Flags); }
76 }
77
78 public IEnumerable<MemberInfo> DeclaredMembers
79 {
80 get { return GetMembers(Flags); }
81 }
82
83 public IEnumerable<MethodInfo> DeclaredMethods
84 {
85 get { return GetMethods(Flags); }
86 }
87
88 public IEnumerable<TypeInfo> DeclaredNestedTypes
89 {
90 get
91 {
92 var types = GetNestedTypes(Flags);
93 var typeInfos = new TypeInfo[types.Length];
94 for (int i = 0; i < types.Length; i++)
95 typeInfos[i] = types[i].GetTypeInfo();
96
97 return typeInfos;
98 }
99 }
100
101 public IEnumerable<PropertyInfo> DeclaredProperties
102 {
103 get { return GetProperties(Flags); }
104 }
105
106 public Type[] GenericTypeParameters
107 {
108 get { return IsGenericTypeDefinition ? GetGenericArguments() : Type.EmptyTypes; }
109 }
110
111 public IEnumerable<Type> ImplementedInterfaces
112 {
113 get { return __GetDeclaredInterfaces(); }
114 }
115
116 public Type AsType()
117 {
118 return this;
119 }
120
121 public EventInfo GetDeclaredEvent(string name)
122 {
123 return GetEvent(name, Flags);
124 }
125
126 public FieldInfo GetDeclaredField(string name)
127 {
128 return GetField(name, Flags);
129 }
130
131 public MethodInfo GetDeclaredMethod(string name)
132 {
133 return GetMethod(name, Flags);
134 }
135
136 public IEnumerable<MethodInfo> GetDeclaredMethods(string name)
137 {
138 var methods = new List<MethodInfo>();
139 foreach (var method in GetMethods(Flags))
140 if (method.Name == name)
141 methods.Add(method);
142
143 return methods;
144 }
145
146 public TypeInfo GetDeclaredNestedType(string name)
147 {
148 return GetNestedType(name, Flags).GetTypeInfo();
149 }
150
151 public PropertyInfo GetDeclaredProperty(string name)
152 {
153 return GetProperty(name, Flags);
154 }
155
156 public bool IsAssignableFrom(TypeInfo typeInfo)
157 {
158 return base.IsAssignableFrom(typeInfo);
159 }
160
161 }
162
163}
IKVM.Reflection.Type Type
IKVM.Reflection.EventInfo EventInfo
IKVM.Reflection.FieldInfo FieldInfo
IKVM.Reflection.PropertyInfo PropertyInfo
IKVM.Reflection.MethodInfo MethodInfo