* Makefile.am:
[monodevelop.git] / extras / MonoDevelop.Debugger.Mdb / Mono.Debugging.Server.Mdb / TypeValueReference.cs
blobb695e8c0ce8b2f7e8aa23bada4fb14a06d596b20
1 // TypeValueReference.cs
2 //
3 // Author:
4 // Lluis Sanchez Gual <lluis@novell.com>
5 //
6 // Copyright (c) 2008 Novell, Inc (http://www.novell.com)
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 // THE SOFTWARE.
28 using System;
29 using System.Collections.Generic;
30 using Mono.Debugger;
31 using Mono.Debugger.Languages;
32 using Mono.Debugging.Client;
34 namespace DebuggerServer
36 public class TypeValueReference: ValueReference
38 TargetType type;
39 string name;
41 public TypeValueReference (EvaluationContext ctx, TargetType type): base (ctx)
43 this.type = type;
44 int i = type.Name.LastIndexOf ('.');
45 if (i != -1)
46 this.name = type.Name.Substring (i+1);
47 else
48 this.name = type.Name;
50 // Make sure the type is initialized
51 try {
52 ObjectUtil.GetTypeOf (ctx, type);
53 } catch {
54 // Ignore
58 public override TargetObject Value {
59 get {
60 throw new NotSupportedException ();
62 set {
63 throw new NotSupportedException();
68 public override TargetType Type {
69 get {
70 return type;
75 public override object ObjectValue {
76 get {
77 throw new NotSupportedException ();
82 public override string Name {
83 get {
84 return name;
88 public override ObjectValueFlags Flags {
89 get {
90 return ObjectValueFlags.Type;
94 protected override ObjectValue OnCreateObjectValue ()
96 return Mono.Debugging.Client.ObjectValue.CreateObject (this, new ObjectPath (Name), "<type>", Name, Flags, null);
99 public override ValueReference GetChild (string name)
101 foreach (ValueReference val in Util.GetMembers (Context, type, null)) {
102 if (val.Name == name)
103 return val;
105 return null;
108 public override ObjectValue[] GetChildren (Mono.Debugging.Client.ObjectPath path, int index, int count)
110 try {
111 List<ObjectValue> list = new List<ObjectValue> ();
112 foreach (ValueReference val in Util.GetMembers (Context, type, null))
113 list.Add (val.CreateObjectValue ());
114 return list.ToArray ();
115 } catch (Exception ex) {
116 Console.WriteLine (ex);
117 Server.Instance.WriteDebuggerOutput (ex.Message);
118 return new ObjectValue [0];
122 public override IEnumerable<ValueReference> GetChildReferences ()
124 try {
125 IEnumerable<ValueReference> rr = Util.GetMembers (Context, type, null);
126 return rr;
127 } catch (Exception ex) {
128 Console.WriteLine (ex);
129 Server.Instance.WriteDebuggerOutput (ex.Message);
130 return new ValueReference [0];