public static VariableItem GetChild(ThreadMirror thread, VariableItem parentItem, TypeMirror parent, int index)
{
var props = (from p in parent.GetAllProperties() where p.HasSimpleGetter() && (p.GetGetMethod(true) != null && p.GetGetMethod(true).IsStatic) || (p.GetSetMethod(true) != null && p.GetSetMethod(true).IsStatic) select p).ToArray();
if (index < props.Length)
{
PropertyInfoMirror prop = props[index];
MethodMirror method = parent.ResolveProperty(prop.Name);
Value child = parent.InvokeMethod(thread, method, new Value[0], InvokeOptions.DisableBreakpoints | InvokeOptions.SingleThreaded);
return new VariableItem(thread, prop.Name, parentItem, prop, child, index);
}
else
{
var fields = from f in parent.GetAllFields() where f.IsStatic select f;
FieldInfoMirror field = fields.ElementAt(index - props.Length);
Value child;
if (field.HasCustomAttribute("System.ThreadStaticAttribute"))
child = field.DeclaringType.GetValue(field, thread);
else
child = field.DeclaringType.GetValue(field);
return new VariableItem(thread, field.Name, parentItem, index, child, index);
}
}