2 Copyright (C) 2009 Jeroen Frijters
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.
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:
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.
26 namespace IKVM.Reflection
28 public abstract class PropertyInfo : MemberInfo
30 // prevent external subclasses
31 internal PropertyInfo()
35 public sealed override MemberTypes MemberType
37 get { return MemberTypes.Property; }
40 public abstract PropertyAttributes Attributes { get; }
41 public abstract bool CanRead { get; }
42 public abstract bool CanWrite { get; }
43 public abstract MethodInfo GetGetMethod(bool nonPublic);
44 public abstract MethodInfo GetSetMethod(bool nonPublic);
45 public abstract MethodInfo[] GetAccessors(bool nonPublic);
46 public abstract object GetRawConstantValue();
47 internal abstract bool IsPublic { get; }
48 internal abstract bool IsStatic { get; }
49 internal abstract PropertySignature PropertySignature { get; }
51 private sealed class ParameterInfoImpl : ParameterInfo
53 private readonly PropertyInfo property;
54 private readonly int parameter;
56 internal ParameterInfoImpl(PropertyInfo property, int parameter)
58 this.property = property;
59 this.parameter = parameter;
62 public override string Name
67 public override Type ParameterType
69 get { return property.PropertySignature.GetParameter(parameter); }
72 public override ParameterAttributes Attributes
74 get { return ParameterAttributes.None; }
77 public override int Position
79 get { return parameter; }
82 public override object RawDefaultValue
84 get { throw new InvalidOperationException(); }
87 public override CustomModifiers __GetCustomModifiers()
89 return property.PropertySignature.GetParameterCustomModifiers(parameter);
92 public override MemberInfo Member
94 get { return property; }
97 public override int MetadataToken
99 get { return 0x08000000; }
102 internal override Module Module
104 get { return property.Module; }
108 public ParameterInfo[] GetIndexParameters()
110 ParameterInfo[] parameters = new ParameterInfo[this.PropertySignature.ParameterCount];
111 for (int i = 0; i < parameters.Length; i++)
113 parameters[i] = new ParameterInfoImpl(this, i);
118 public Type PropertyType
120 get { return this.PropertySignature.PropertyType; }
123 public CustomModifiers __GetCustomModifiers()
125 return this.PropertySignature.GetCustomModifiers();
128 public Type[] GetRequiredCustomModifiers()
130 return __GetCustomModifiers().GetRequired();
133 public Type[] GetOptionalCustomModifiers()
135 return __GetCustomModifiers().GetOptional();
138 public bool IsSpecialName
140 get { return (Attributes & PropertyAttributes.SpecialName) != 0; }
143 public MethodInfo GetGetMethod()
145 return GetGetMethod(false);
148 public MethodInfo GetSetMethod()
150 return GetSetMethod(false);
153 public MethodInfo[] GetAccessors()
155 return GetAccessors(false);
158 public CallingConventions __CallingConvention
160 get { return this.PropertySignature.CallingConvention; }
163 internal virtual PropertyInfo BindTypeParameters(Type type)
165 return new GenericPropertyInfo(this.DeclaringType.BindTypeParameters(type), this);
168 public override string ToString()
170 return this.DeclaringType.ToString() + " " + Name;