~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« 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: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
using System;
2
 
using System.Collections.Generic;
3
 
using System.Linq;
4
 
using System.Text;
5
 
using System.Reflection;
6
 
using Mono.Debugging.Client;
7
 
using Mono.Debugging.Backend;
8
 
using System.Diagnostics;
9
 
 
10
 
namespace Mono.Debugging.Evaluation
11
 
{
12
 
        public class FilteredMembersSource: RemoteFrameObject, IObjectValueSource
13
 
        {
14
 
                object obj;
15
 
                object type;
16
 
                EvaluationContext ctx;
17
 
                BindingFlags bindingFlags;
18
 
                IObjectSource objectSource;
19
 
 
20
 
                public FilteredMembersSource (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, BindingFlags bindingFlags)
21
 
                {
22
 
                        this.ctx = ctx;
23
 
                        this.obj = obj;
24
 
                        this.type = type;
25
 
                        this.bindingFlags = bindingFlags;
26
 
                        this.objectSource = objectSource;
27
 
                }
28
 
 
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);
42
 
                        src.Connect ();
43
 
                        ObjectValue val = ObjectValue.CreateObject (src, new ObjectPath (label), "", "", ObjectValueFlags.Group|ObjectValueFlags.ReadOnly|ObjectValueFlags.NoRefresh, null);
44
 
                        val.ChildSelector = "";
45
 
                        return val;
46
 
                }
47
 
 
48
 
                public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
49
 
                {
50
 
                        EvaluationContext cctx = ctx.WithOptions (options);
51
 
                        var names = new ObjectValueNameTracker (cctx);
52
 
                        object tdataType = null;
53
 
                        TypeDisplayData tdata = null;
54
 
                        List<ObjectValue> list = new List<ObjectValue> ();
55
 
                        foreach (ValueReference val in cctx.Adapter.GetMembersSorted (cctx, objectSource, type, obj, bindingFlags)) {
56
 
                                object decType = val.DeclaringType;
57
 
                                if (decType != null && decType != tdataType) {
58
 
                                        tdataType = decType;
59
 
                                        tdata = cctx.Adapter.GetTypeDisplayData (cctx, decType);
60
 
                                }
61
 
                                DebuggerBrowsableState state = tdata.GetMemberBrowsableState (val.Name);
62
 
                                if (state == DebuggerBrowsableState.Never)
63
 
                                        continue;
64
 
                                ObjectValue oval = val.CreateObjectValue (options);
65
 
                                names.FixName (val, oval);
66
 
                                list.Add (oval);
67
 
                        }
68
 
                        if ((bindingFlags & BindingFlags.NonPublic) == 0) {
69
 
                                BindingFlags newFlags = bindingFlags | BindingFlags.NonPublic;
70
 
                                newFlags &= ~BindingFlags.Public;
71
 
                                list.Add (CreateNonPublicsNode (cctx, objectSource, type, obj, newFlags));
72
 
                        }
73
 
                        return list.ToArray ();
74
 
                }
75
 
                
76
 
                public ObjectValue GetValue (ObjectPath path, EvaluationOptions options)
77
 
                {
78
 
                        throw new NotSupportedException ();
79
 
                }
80
 
 
81
 
                public EvaluationResult SetValue (ObjectPath path, string value, EvaluationOptions options)
82
 
                {
83
 
                        throw new NotSupportedException ();
84
 
                }
85
 
                
86
 
                public object GetRawValue (ObjectPath path, EvaluationOptions options)
87
 
                {
88
 
                        throw new System.NotImplementedException ();
89
 
                }
90
 
                
91
 
                public void SetRawValue (ObjectPath path, object value, EvaluationOptions options)
92
 
                {
93
 
                        throw new System.NotImplementedException ();
94
 
                }
95
 
        }
96
 
}
 
1
using System;
 
2
using System.Collections.Generic;
 
3
using System.Linq;
 
4
using System.Text;
 
5
using System.Reflection;
 
6
using Mono.Debugging.Client;
 
7
using Mono.Debugging.Backend;
 
8
using System.Diagnostics;
 
9
 
 
10
namespace Mono.Debugging.Evaluation
 
11
{
 
12
        public class FilteredMembersSource: RemoteFrameObject, IObjectValueSource
 
13
        {
 
14
                object obj;
 
15
                object type;
 
16
                EvaluationContext ctx;
 
17
                BindingFlags bindingFlags;
 
18
                IObjectSource objectSource;
 
19
 
 
20
                public FilteredMembersSource (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, BindingFlags bindingFlags)
 
21
                {
 
22
                        this.ctx = ctx;
 
23
                        this.obj = obj;
 
24
                        this.type = type;
 
25
                        this.bindingFlags = bindingFlags;
 
26
                        this.objectSource = objectSource;
 
27
                }
 
28
 
 
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);
 
42
                        src.Connect ();
 
43
                        ObjectValue val = ObjectValue.CreateObject (src, new ObjectPath (label), "", "", ObjectValueFlags.Group|ObjectValueFlags.ReadOnly|ObjectValueFlags.NoRefresh, null);
 
44
                        val.ChildSelector = "";
 
45
                        return val;
 
46
                }
 
47
 
 
48
                public ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
 
49
                {
 
50
                        EvaluationContext cctx = ctx.WithOptions (options);
 
51
                        var names = new ObjectValueNameTracker (cctx);
 
52
                        object tdataType = null;
 
53
                        TypeDisplayData tdata = null;
 
54
                        List<ObjectValue> list = new List<ObjectValue> ();
 
55
                        foreach (ValueReference val in cctx.Adapter.GetMembersSorted (cctx, objectSource, type, obj, bindingFlags)) {
 
56
                                object decType = val.DeclaringType;
 
57
                                if (decType != null && decType != tdataType) {
 
58
                                        tdataType = decType;
 
59
                                        tdata = cctx.Adapter.GetTypeDisplayData (cctx, decType);
 
60
                                }
 
61
                                DebuggerBrowsableState state = tdata.GetMemberBrowsableState (val.Name);
 
62
                                if (state == DebuggerBrowsableState.Never)
 
63
                                        continue;
 
64
                                ObjectValue oval = val.CreateObjectValue (options);
 
65
                                names.FixName (val, oval);
 
66
                                list.Add (oval);
 
67
                        }
 
68
                        if ((bindingFlags & BindingFlags.NonPublic) == 0) {
 
69
                                BindingFlags newFlags = bindingFlags | BindingFlags.NonPublic;
 
70
                                newFlags &= ~BindingFlags.Public;
 
71
                                list.Add (CreateNonPublicsNode (cctx, objectSource, type, obj, newFlags));
 
72
                        }
 
73
                        return list.ToArray ();
 
74
                }
 
75
                
 
76
                public ObjectValue GetValue (ObjectPath path, EvaluationOptions options)
 
77
                {
 
78
                        throw new NotSupportedException ();
 
79
                }
 
80
 
 
81
                public EvaluationResult SetValue (ObjectPath path, string value, EvaluationOptions options)
 
82
                {
 
83
                        throw new NotSupportedException ();
 
84
                }
 
85
                
 
86
                public object GetRawValue (ObjectPath path, EvaluationOptions options)
 
87
                {
 
88
                        throw new System.NotImplementedException ();
 
89
                }
 
90
                
 
91
                public void SetRawValue (ObjectPath path, object value, EvaluationOptions options)
 
92
                {
 
93
                        throw new System.NotImplementedException ();
 
94
                }
 
95
        }
 
96
}