2 using System.Collections.Generic;
4 using System.Reflection;
6 using Mono.Cecil.Metadata;
8 namespace Mono.Debugger.Soft
10 public class PropertyInfoMirror : Mirror {
14 PropertyAttributes attrs;
15 MethodMirror get_method, set_method;
16 CustomAttributeDataMirror[] cattrs;
17 C.PropertyDefinition meta;
19 public PropertyInfoMirror (TypeMirror parent, long id, string name, MethodMirror get_method, MethodMirror set_method, PropertyAttributes attrs) : base (parent.VirtualMachine, id) {
23 this.get_method = get_method;
24 this.set_method = set_method;
27 public TypeMirror DeclaringType {
39 public TypeMirror PropertyType {
41 if (get_method != null)
42 return get_method.ReturnType;
44 ParameterInfoMirror[] parameters = set_method.GetParameters ();
46 return parameters [parameters.Length - 1].ParameterType;
51 public PropertyAttributes Attributes {
57 public bool IsSpecialName {
58 get {return (Attributes & PropertyAttributes.SpecialName) != 0;}
61 public MethodMirror GetGetMethod ()
63 return GetGetMethod (false);
66 public MethodMirror GetGetMethod (bool nonPublic)
68 if (get_method != null && (nonPublic || get_method.IsPublic))
74 public MethodMirror GetSetMethod ()
76 return GetSetMethod (false);
79 public MethodMirror GetSetMethod (bool nonPublic)
81 if (set_method != null && (nonPublic || set_method.IsPublic))
87 public ParameterInfoMirror[] GetIndexParameters()
89 if (get_method != null)
90 return get_method.GetParameters ();
91 return new ParameterInfoMirror [0];
94 public C.PropertyDefinition Metadata {
96 if (parent.Metadata == null)
98 // FIXME: Speed this up
99 foreach (var def in parent.Metadata.Properties) {
100 if (def.Name == Name) {
106 /* Shouldn't happen */
107 throw new NotImplementedException ();
112 public CustomAttributeDataMirror[] GetCustomAttributes (bool inherit) {
113 return GetCAttrs (null, inherit);
116 public CustomAttributeDataMirror[] GetCustomAttributes (TypeMirror attributeType, bool inherit) {
117 if (attributeType == null)
118 throw new ArgumentNullException ("attributeType");
119 return GetCAttrs (attributeType, inherit);
122 CustomAttributeDataMirror[] GetCAttrs (TypeMirror type, bool inherit) {
123 if (cattrs == null && Metadata != null && !Metadata.HasCustomAttributes)
124 cattrs = new CustomAttributeDataMirror [0];
126 // FIXME: Handle inherit
127 if (cattrs == null) {
128 CattrInfo[] info = vm.conn.Type_GetPropertyCustomAttributes (DeclaringType.Id, id, 0, false);
129 cattrs = CustomAttributeDataMirror.Create (vm, info);
131 var res = new List<CustomAttributeDataMirror> ();
132 foreach (var attr in cattrs)
133 if (type == null || attr.Constructor.DeclaringType == type)
135 return res.ToArray ();