~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ikvm/reflect/ParameterInfo.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
*/
 
24
using System.Collections.Generic;
 
25
 
 
26
namespace IKVM.Reflection
 
27
{
 
28
        public abstract class ParameterInfo : ICustomAttributeProvider
 
29
        {
 
30
                // prevent external subclasses
 
31
                internal ParameterInfo()
 
32
                {
 
33
                }
 
34
 
 
35
                public sealed override bool Equals(object obj)
 
36
                {
 
37
                        ParameterInfo other = obj as ParameterInfo;
 
38
                        return other != null && other.Member == this.Member && other.Position == this.Position;
 
39
                }
 
40
 
 
41
                public sealed override int GetHashCode()
 
42
                {
 
43
                        return this.Member.GetHashCode() * 1777 + this.Position;
 
44
                }
 
45
 
 
46
                public static bool operator ==(ParameterInfo p1, ParameterInfo p2)
 
47
                {
 
48
                        return ReferenceEquals(p1, p2) || (!ReferenceEquals(p1, null) && p1.Equals(p2));
 
49
                }
 
50
 
 
51
                public static bool operator !=(ParameterInfo p1, ParameterInfo p2)
 
52
                {
 
53
                        return !(p1 == p2);
 
54
                }
 
55
 
 
56
                public abstract string Name { get; }
 
57
                public abstract Type ParameterType { get; }
 
58
                public abstract ParameterAttributes Attributes { get; }
 
59
                public abstract int Position { get; }
 
60
                public abstract object RawDefaultValue { get; }
 
61
                public abstract CustomModifiers __GetCustomModifiers();
 
62
                public abstract bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal);
 
63
                public abstract MemberInfo Member { get; }
 
64
                public abstract int MetadataToken { get; }
 
65
                internal abstract Module Module { get; }
 
66
 
 
67
                public Type[] GetOptionalCustomModifiers()
 
68
                {
 
69
                        return __GetCustomModifiers().GetOptional();
 
70
                }
 
71
 
 
72
                public Type[] GetRequiredCustomModifiers()
 
73
                {
 
74
                        return __GetCustomModifiers().GetRequired();
 
75
                }
 
76
 
 
77
                public bool IsIn
 
78
                {
 
79
                        get { return (Attributes & ParameterAttributes.In) != 0; }
 
80
                }
 
81
 
 
82
                public bool IsOut
 
83
                {
 
84
                        get { return (Attributes & ParameterAttributes.Out) != 0; }
 
85
                }
 
86
 
 
87
                public bool IsLcid
 
88
                {
 
89
                        get { return (Attributes & ParameterAttributes.Lcid) != 0; }
 
90
                }
 
91
 
 
92
                public bool IsRetval
 
93
                {
 
94
                        get { return (Attributes & ParameterAttributes.Retval) != 0; }
 
95
                }
 
96
 
 
97
                public bool IsOptional
 
98
                {
 
99
                        get { return (Attributes & ParameterAttributes.Optional) != 0; }
 
100
                }
 
101
 
 
102
                public bool HasDefaultValue
 
103
                {
 
104
                        get { return (Attributes & ParameterAttributes.HasDefault) != 0; }
 
105
                }
 
106
 
 
107
                public bool IsDefined(Type attributeType, bool inherit)
 
108
                {
 
109
                        return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0;
 
110
                }
 
111
 
 
112
                public IList<CustomAttributeData> __GetCustomAttributes(Type attributeType, bool inherit)
 
113
                {
 
114
                        return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit);
 
115
                }
 
116
 
 
117
                public IList<CustomAttributeData> GetCustomAttributesData()
 
118
                {
 
119
                        return CustomAttributeData.GetCustomAttributes(this);
 
120
                }
 
121
 
 
122
                public IEnumerable<CustomAttributeData> CustomAttributes
 
123
                {
 
124
                        get { return GetCustomAttributesData(); }
 
125
                }
 
126
        }
 
127
 
 
128
        sealed class ParameterInfoWrapper : ParameterInfo
 
129
        {
 
130
                private readonly MemberInfo member;
 
131
                private readonly ParameterInfo forward;
 
132
 
 
133
                internal ParameterInfoWrapper(MemberInfo member, ParameterInfo forward)
 
134
                {
 
135
                        this.member = member;
 
136
                        this.forward = forward;
 
137
                }
 
138
 
 
139
                public override string Name
 
140
                {
 
141
                        get { return forward.Name; }
 
142
                }
 
143
 
 
144
                public override Type ParameterType
 
145
                {
 
146
                        get { return forward.ParameterType; }
 
147
                }
 
148
 
 
149
                public override ParameterAttributes Attributes
 
150
                {
 
151
                        get { return forward.Attributes; }
 
152
                }
 
153
 
 
154
                public override int Position
 
155
                {
 
156
                        get { return forward.Position; }
 
157
                }
 
158
 
 
159
                public override object RawDefaultValue
 
160
                {
 
161
                        get { return forward.RawDefaultValue; }
 
162
                }
 
163
 
 
164
                public override CustomModifiers __GetCustomModifiers()
 
165
                {
 
166
                        return forward.__GetCustomModifiers();
 
167
                }
 
168
 
 
169
                public override bool __TryGetFieldMarshal(out FieldMarshal fieldMarshal)
 
170
                {
 
171
                        return forward.__TryGetFieldMarshal(out fieldMarshal);
 
172
                }
 
173
 
 
174
                public override MemberInfo Member
 
175
                {
 
176
                        get { return member; }
 
177
                }
 
178
 
 
179
                public override int MetadataToken
 
180
                {
 
181
                        get { return forward.MetadataToken; }
 
182
                }
 
183
 
 
184
                internal override Module Module
 
185
                {
 
186
                        get { return member.Module; }
 
187
                }
 
188
        }
 
189
}