~ubuntu-branches/ubuntu/natty/monodevelop/natty

« back to all changes in this revision

Viewing changes to src/core/Mono.Debugging/Mono.Debugging.Evaluation/FilteredMembersSource.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-01-07 19:06:58 UTC
  • mto: (1.6.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 46.
  • Revision ID: james.westby@ubuntu.com-20100107190658-z9z95lgk4kwfes7p
ImportĀ upstreamĀ versionĀ 2.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
using System.Reflection;
6
6
using Mono.Debugging.Client;
7
7
using Mono.Debugging.Backend;
 
8
using System.Diagnostics;
8
9
 
9
10
namespace Mono.Debugging.Evaluation
10
11
{
14
15
                object type;
15
16
                EvaluationContext ctx;
16
17
                BindingFlags bindingFlags;
 
18
                IObjectSource objectSource;
17
19
 
18
 
                public FilteredMembersSource (EvaluationContext ctx, object type, object obj, BindingFlags bindingFlags)
 
20
                public FilteredMembersSource (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, BindingFlags bindingFlags)
19
21
                {
20
22
                        this.ctx = ctx;
21
23
                        this.obj = obj;
22
24
                        this.type = type;
23
25
                        this.bindingFlags = bindingFlags;
 
26
                        this.objectSource = objectSource;
24
27
                }
25
28
 
26
 
                public static ObjectValue CreateNode (EvaluationContext ctx, object type, object obj, BindingFlags bindingFlags)
27
 
                {
28
 
                        FilteredMembersSource src = new FilteredMembersSource (ctx, type, obj, bindingFlags);
 
29
                public static ObjectValue CreateNonPublicsNode (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, BindingFlags bindingFlags)
 
30
                {
 
31
                        return CreateNode (ctx, objectSource, type, obj, bindingFlags, "Non-public members");
 
32
                }
 
33
                
 
34
                public static ObjectValue CreateStaticsNode (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, BindingFlags bindingFlags)
 
35
                {
 
36
                        return CreateNode (ctx, objectSource, type, obj, bindingFlags, "Static members");
 
37
                }
 
38
                
 
39
                static ObjectValue CreateNode (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, BindingFlags bindingFlags, string label)
 
40
                {
 
41
                        FilteredMembersSource src = new FilteredMembersSource (ctx, objectSource, type, obj, bindingFlags);
29
42
                        src.Connect ();
30
 
                        string label;
31
 
                        if ((bindingFlags & BindingFlags.NonPublic) != 0)
32
 
                                label = "Non-public members";
33
 
                        else
34
 
                                label = "Static members";
35
 
                        return ObjectValue.CreateObject (src, new ObjectPath (label), "", "", ObjectValueFlags.ReadOnly, null);
 
43
                        return ObjectValue.CreateObject (src, new ObjectPath (label), "", "", ObjectValueFlags.Group|ObjectValueFlags.ReadOnly|ObjectValueFlags.NoRefresh, null);
36
44
                }
37
45
 
38
46
                public ObjectValue[] GetChildren (ObjectPath path, int index, int count)
39
47
                {
 
48
                        var names = new ObjectValueNameTracker (ctx);
 
49
                        object tdataType = null;
 
50
                        TypeDisplayData tdata = null;
40
51
                        List<ObjectValue> list = new List<ObjectValue> ();
41
 
                        foreach (ValueReference val in ctx.Adapter.GetMembersSorted (ctx, type, obj, bindingFlags)) {
42
 
                                list.Add (val.CreateObjectValue ());
 
52
                        foreach (ValueReference val in ctx.Adapter.GetMembersSorted (ctx, objectSource, type, obj, bindingFlags)) {
 
53
                                object decType = val.DeclaringType;
 
54
                                if (decType != null && decType != tdataType) {
 
55
                                        tdataType = decType;
 
56
                                        tdata = ctx.Adapter.GetTypeDisplayData (ctx, decType);
 
57
                                }
 
58
                                DebuggerBrowsableState state = tdata.GetMemberBrowsableState (val.Name);
 
59
                                if (state == DebuggerBrowsableState.Never)
 
60
                                        continue;
 
61
                                ObjectValue oval = val.CreateObjectValue ();
 
62
                                names.FixName (val, oval);
 
63
                                list.Add (oval);
43
64
                        }
44
65
                        if ((bindingFlags & BindingFlags.NonPublic) == 0) {
45
66
                                BindingFlags newFlags = bindingFlags | BindingFlags.NonPublic;
46
67
                                newFlags &= ~BindingFlags.Public;
47
 
                                list.Add (CreateNode (ctx, type, obj, newFlags));
 
68
                                list.Add (CreateNonPublicsNode (ctx, objectSource, type, obj, newFlags));
48
69
                        }
49
70
                        return list.ToArray ();
50
71
                }
 
72
                
 
73
                public ObjectValue GetValue (ObjectPath path, EvaluationOptions options)
 
74
                {
 
75
                        throw new NotSupportedException ();
 
76
                }
51
77
 
52
78
                public string SetValue (ObjectPath path, string value)
53
79
                {