1 // TypeValueReference.cs
4 // Lluis Sanchez Gual <lluis@novell.com>
6 // Copyright (c) 2008 Novell, Inc (http://www.novell.com)
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
29 using System
.Collections
.Generic
;
31 using Mono
.Debugger
.Languages
;
32 using Mono
.Debugging
.Client
;
34 namespace DebuggerServer
36 public class TypeValueReference
: ValueReference
41 public TypeValueReference (EvaluationContext ctx
, TargetType type
): base (ctx
)
44 int i
= type
.Name
.LastIndexOf ('.');
46 this.name
= type
.Name
.Substring (i
+1);
48 this.name
= type
.Name
;
50 // Make sure the type is initialized
52 ObjectUtil
.GetTypeOf (ctx
, type
);
58 public override TargetObject Value
{
60 throw new NotSupportedException ();
63 throw new NotSupportedException();
68 public override TargetType Type
{
75 public override object ObjectValue
{
77 throw new NotSupportedException ();
82 public override string Name
{
88 public override ObjectValueFlags Flags
{
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
)
108 public override ObjectValue
[] GetChildren (Mono
.Debugging
.Client
.ObjectPath path
, int index
, int count
)
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 ()
125 IEnumerable
<ValueReference
> rr
= Util
.GetMembers (Context
, type
, null);
127 } catch (Exception ex
) {
128 Console
.WriteLine (ex
);
129 Server
.Instance
.WriteDebuggerOutput (ex
.Message
);
130 return new ValueReference
[0];