IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
GenericPropertyInfo.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009, 2010 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*/
24namespace IKVM.Reflection
25{
26
27 sealed class GenericPropertyInfo : PropertyInfo
28 {
29
30 readonly Type typeInstance;
31 readonly PropertyInfo property;
32
38 internal GenericPropertyInfo(Type typeInstance, PropertyInfo property)
39 {
40 this.typeInstance = typeInstance;
41 this.property = property;
42 }
43
44 public override bool Equals(object obj)
45 {
46 var other = obj as GenericPropertyInfo;
47 return other != null && other.typeInstance == typeInstance && other.property == property;
48 }
49
50 public override int GetHashCode()
51 {
52 return typeInstance.GetHashCode() * 537 + property.GetHashCode();
53 }
54
55 public override PropertyAttributes Attributes
56 {
57 get { return property.Attributes; }
58 }
59
60 public override bool CanRead
61 {
62 get { return property.CanRead; }
63 }
64
65 public override bool CanWrite
66 {
67 get { return property.CanWrite; }
68 }
69
70 private MethodInfo Wrap(MethodInfo method)
71 {
72 if (method == null)
73 return null;
74
75 return new GenericMethodInstance(typeInstance, method, null);
76 }
77
78 public override MethodInfo GetGetMethod(bool nonPublic)
79 {
80 return Wrap(property.GetGetMethod(nonPublic));
81 }
82
83 public override MethodInfo GetSetMethod(bool nonPublic)
84 {
85 return Wrap(property.GetSetMethod(nonPublic));
86 }
87
88 public override MethodInfo[] GetAccessors(bool nonPublic)
89 {
90 var accessors = property.GetAccessors(nonPublic);
91 for (int i = 0; i < accessors.Length; i++)
92 accessors[i] = Wrap(accessors[i]);
93
94 return accessors;
95 }
96
97 public override object GetRawConstantValue()
98 {
99 return property.GetRawConstantValue();
100 }
101
102 internal override bool IsPublic
103 {
104 get { return property.IsPublic; }
105 }
106
107 internal override bool IsNonPrivate
108 {
109 get { return property.IsNonPrivate; }
110 }
111
112 internal override bool IsStatic
113 {
114 get { return property.IsStatic; }
115 }
116
117 internal override PropertySignature PropertySignature
118 {
119 get { return property.PropertySignature.ExpandTypeParameters(typeInstance); }
120 }
121
122 public override string Name
123 {
124 get { return property.Name; }
125 }
126
127 public override Type DeclaringType
128 {
129 get { return typeInstance; }
130 }
131
132 public override Module Module
133 {
134 get { return typeInstance.Module; }
135 }
136
137 public override int MetadataToken
138 {
139 get { return property.MetadataToken; }
140 }
141
142 internal override PropertyInfo BindTypeParameters(Type type)
143 {
144 return new GenericPropertyInfo(typeInstance.BindTypeParameters(type), property);
145 }
146
147 internal override bool IsBaked
148 {
149 get { return property.IsBaked; }
150 }
151
152 internal override int GetCurrentToken()
153 {
154 return property.GetCurrentToken();
155 }
156
157 }
158
159}
global::java.lang.invoke.LambdaForm.Name Name
override MethodInfo[] GetAccessors(bool nonPublic)
override MethodInfo GetGetMethod(bool nonPublic)
override PropertyAttributes Attributes
override MethodInfo GetSetMethod(bool nonPublic)