IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ParameterInfo.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009 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 ParameterInfo : ICustomAttributeProvider
30 {
31
35 public ParameterInfo()
36 {
37
38 }
39
40 public sealed override bool Equals(object obj)
41 {
42 var other = obj as ParameterInfo;
43 return other != null && other.Member == Member && other.Position == Position;
44 }
45
46 public sealed override int GetHashCode()
47 {
48 return Member.GetHashCode() * 1777 + Position;
49 }
50
51 public static bool operator ==(ParameterInfo p1, ParameterInfo p2)
52 {
53 return ReferenceEquals(p1, p2) || (!ReferenceEquals(p1, null) && p1.Equals(p2));
54 }
55
56 public static bool operator !=(ParameterInfo p1, ParameterInfo p2)
57 {
58 return !(p1 == p2);
59 }
60
61 public abstract string Name { get; }
62
63 public abstract Type ParameterType { get; }
64
65 public abstract ParameterAttributes Attributes { get; }
66
67 public abstract int Position { get; }
68
69 public abstract object RawDefaultValue { get; }
70
71 public abstract CustomModifiers __GetCustomModifiers();
72
73 public abstract bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal);
74
75 public abstract MemberInfo Member { get; }
76
77 public abstract int MetadataToken { get; }
78
79 public abstract Module Module { get; }
80
81 public Type[] GetOptionalCustomModifiers()
82 {
83 return __GetCustomModifiers().GetOptional();
84 }
85
86 public Type[] GetRequiredCustomModifiers()
87 {
88 return __GetCustomModifiers().GetRequired();
89 }
90
91 public bool IsIn
92 {
93 get { return (Attributes & ParameterAttributes.In) != 0; }
94 }
95
96 public bool IsOut
97 {
98 get { return (Attributes & ParameterAttributes.Out) != 0; }
99 }
100
101 public bool IsLcid
102 {
103 get { return (Attributes & ParameterAttributes.Lcid) != 0; }
104 }
105
106 public bool IsRetval
107 {
108 get { return (Attributes & ParameterAttributes.Retval) != 0; }
109 }
110
111 public bool IsOptional
112 {
113 get { return (Attributes & ParameterAttributes.Optional) != 0; }
114 }
115
116 public bool HasDefaultValue
117 {
118 get { return (Attributes & ParameterAttributes.HasDefault) != 0; }
119 }
120
121 public bool IsDefined(Type attributeType, bool inherit)
122 {
123 return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0;
124 }
125
126 public IList<CustomAttributeData> __GetCustomAttributes(Type attributeType, bool inherit)
127 {
128 return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit);
129 }
130
131 public IList<CustomAttributeData> GetCustomAttributesData()
132 {
133 return CustomAttributeData.GetCustomAttributes(this);
134 }
135
136 public IEnumerable<CustomAttributeData> CustomAttributes
137 {
138 get { return GetCustomAttributesData(); }
139 }
140 }
141
142 sealed class ParameterInfoWrapper : ParameterInfo
143 {
144
145 readonly MemberInfo member;
146 readonly ParameterInfo forward;
147
153 internal ParameterInfoWrapper(MemberInfo member, ParameterInfo forward)
154 {
155 this.member = member;
156 this.forward = forward;
157 }
158
159 public override string Name
160 {
161 get { return forward.Name; }
162 }
163
164 public override Type ParameterType
165 {
166 get { return forward.ParameterType; }
167 }
168
169 public override ParameterAttributes Attributes
170 {
171 get { return forward.Attributes; }
172 }
173
174 public override int Position
175 {
176 get { return forward.Position; }
177 }
178
179 public override object RawDefaultValue
180 {
181 get { return forward.RawDefaultValue; }
182 }
183
184 public override CustomModifiers __GetCustomModifiers()
185 {
186 return forward.__GetCustomModifiers();
187 }
188
189 public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal)
190 {
191 return forward.__TryGetFieldMarshal(out fieldMarshal);
192 }
193
194 public override MemberInfo Member
195 {
196 get { return member; }
197 }
198
199 public override int MetadataToken
200 {
201 get { return forward.MetadataToken; }
202 }
203
204 public override Module Module
205 {
206 get { return member.Module; }
207 }
208
209 }
210
211}
IKVM.Reflection.Module Module
IKVM.Reflection.Type Type
IKVM.Reflection.MemberInfo MemberInfo
IKVM.Reflection.ParameterInfo ParameterInfo
global::java.lang.invoke.LambdaForm.Name Name
override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal)
override ParameterAttributes Attributes
override CustomModifiers __GetCustomModifiers()