IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
PropertyInfo.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-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;
25using System.Collections.Generic;
26
27namespace IKVM.Reflection
28{
29
30 internal abstract class PropertyInfo : MemberInfo
31 {
32
36 internal PropertyInfo()
37 {
38
39 }
40
41 public sealed override MemberTypes MemberType => MemberTypes.Property;
42
43 public abstract PropertyAttributes Attributes { get; }
44
45 public abstract bool CanRead { get; }
46
47 public abstract bool CanWrite { get; }
48
49 public abstract MethodInfo GetGetMethod(bool nonPublic);
50
51 public abstract MethodInfo GetSetMethod(bool nonPublic);
52
53 public abstract MethodInfo[] GetAccessors(bool nonPublic);
54
55 public abstract object GetRawConstantValue();
56
57 internal abstract bool IsPublic { get; }
58
59 internal abstract bool IsNonPrivate { get; }
60
61 internal abstract bool IsStatic { get; }
62
63 internal abstract PropertySignature PropertySignature { get; }
64
65 sealed class ParameterInfoImpl : ParameterInfo
66 {
67
68 readonly PropertyInfo property;
69 readonly int parameter;
70
76 internal ParameterInfoImpl(PropertyInfo property, int parameter)
77 {
78 this.property = property;
79 this.parameter = parameter;
80 }
81
82 public override string Name
83 {
84 get { return null; }
85 }
86
87 public override Type ParameterType
88 {
89 get { return property.PropertySignature.GetParameter(parameter); }
90 }
91
92 public override ParameterAttributes Attributes
93 {
94 get { return ParameterAttributes.None; }
95 }
96
97 public override int Position
98 {
99 get { return parameter; }
100 }
101
102 public override object RawDefaultValue
103 {
104 get { throw new InvalidOperationException(); }
105 }
106
107 public override CustomModifiers __GetCustomModifiers()
108 {
109 return property.PropertySignature.GetParameterCustomModifiers(parameter);
110 }
111
112 public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal)
113 {
114 fieldMarshal = new FieldMarshal();
115 return false;
116 }
117
118 public override MemberInfo Member
119 {
120 get { return property; }
121 }
122
123 public override int MetadataToken
124 {
125 get { return 0x08000000; }
126 }
127
128 public override Module Module
129 {
130 get { return property.Module; }
131 }
132
133 }
134
135 public virtual ParameterInfo[] GetIndexParameters()
136 {
137 var parameters = new ParameterInfo[PropertySignature.ParameterCount];
138 for (var i = 0; i < parameters.Length; i++)
139 parameters[i] = new ParameterInfoImpl(this, i);
140
141 return parameters;
142 }
143
144 public Type PropertyType
145 {
146 get { return PropertySignature.PropertyType; }
147 }
148
149 public CustomModifiers __GetCustomModifiers()
150 {
151 return PropertySignature.GetCustomModifiers();
152 }
153
154 public Type[] GetRequiredCustomModifiers()
155 {
156 return __GetCustomModifiers().GetRequired();
157 }
158
159 public Type[] GetOptionalCustomModifiers()
160 {
161 return __GetCustomModifiers().GetOptional();
162 }
163
164 public bool IsSpecialName
165 {
166 get { return (Attributes & PropertyAttributes.SpecialName) != 0; }
167 }
168
169 public MethodInfo GetMethod
170 {
171 get { return GetGetMethod(true); }
172 }
173
174 public MethodInfo SetMethod
175 {
176 get { return GetSetMethod(true); }
177 }
178
179 public MethodInfo GetGetMethod()
180 {
181 return GetGetMethod(false);
182 }
183
184 public MethodInfo GetSetMethod()
185 {
186 return GetSetMethod(false);
187 }
188
189 public MethodInfo[] GetAccessors()
190 {
191 return GetAccessors(false);
192 }
193
194 public CallingConventions __CallingConvention
195 {
196 get { return this.PropertySignature.CallingConvention; }
197 }
198
199 internal virtual PropertyInfo BindTypeParameters(Type type)
200 {
201 return new GenericPropertyInfo(this.DeclaringType.BindTypeParameters(type), this);
202 }
203
204 public override string ToString()
205 {
206 return DeclaringType.ToString() + " " + Name;
207 }
208
209 internal sealed override bool BindingFlagsMatch(BindingFlags flags)
210 {
211 return BindingFlagsMatch(IsPublic, flags, BindingFlags.Public, BindingFlags.NonPublic)
212 && BindingFlagsMatch(IsStatic, flags, BindingFlags.Static, BindingFlags.Instance);
213 }
214
215 internal sealed override bool BindingFlagsMatchInherited(BindingFlags flags)
216 {
217 return IsNonPrivate
218 && BindingFlagsMatch(IsPublic, flags, BindingFlags.Public, BindingFlags.NonPublic)
219 && BindingFlagsMatch(IsStatic, flags, BindingFlags.Static | BindingFlags.FlattenHierarchy, BindingFlags.Instance);
220 }
221
222 internal sealed override MemberInfo SetReflectedType(Type type)
223 {
224 return new PropertyInfoWithReflectedType(type, this);
225 }
226
227 internal sealed override List<CustomAttributeData> GetPseudoCustomAttributes(Type attributeType)
228 {
229 // properties don't have pseudo custom attributes
230 return null;
231 }
232
233 }
234
235}
IKVM.Reflection.Module Module
IKVM.Reflection.Type Type
IKVM.Reflection.MemberInfo MemberInfo
IKVM.Reflection.PropertyInfo PropertyInfo
IKVM.Reflection.MethodInfo MethodInfo
IKVM.Reflection.ParameterInfo ParameterInfo
global::java.lang.invoke.LambdaForm.Name Name