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

« back to all changes in this revision

Viewing changes to src/core/Mono.Debugging/Mono.Debugging.Client/ObjectValue.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:
167
167
                        return ob;
168
168
                }
169
169
                
 
170
                /// <summary>
 
171
                /// Gets the flags of the value
 
172
                /// </summary>
170
173
                public ObjectValueFlags Flags {
171
174
                        get { return flags; }
172
175
                }
173
 
                
 
176
 
 
177
                /// <summary>
 
178
                /// Name of the value (for example, the property name)
 
179
                /// </summary>
174
180
                public string Name {
175
181
                        get {
176
182
                                if (name == null)
182
188
                                name = value;
183
189
                        }
184
190
                }
185
 
                
 
191
 
 
192
                /// <summary>
 
193
                /// Gets or sets the value of the object
 
194
                /// </summary>
 
195
                /// <value>
 
196
                /// The value.
 
197
                /// </value>
 
198
                /// <exception cref='InvalidOperationException'>
 
199
                /// Is thrown when trying to set a value on a read-only ObjectValue
 
200
                /// </exception>
 
201
                /// <remarks>
 
202
                /// This value is a string representation of the ObjectValue. The content depends on several evaluation
 
203
                /// options. For example, if ToString calls are enabled, this value will be the result of calling
 
204
                /// ToString.
 
205
                /// If the object is a primitive type, in general the Value will be an expression that represents the
 
206
                /// value in the target language. For example, when debugging C#, if the property is an string, the value
 
207
                /// will include the quotation marks and chars like '\' will be properly escaped.
 
208
                /// If you need to get the real CLR value of the object, use GetRawValue.
 
209
                /// </remarks>
186
210
                public virtual string Value {
187
211
                        get {
188
212
                                return value;
197
221
                                }
198
222
                        }
199
223
                }
 
224
 
 
225
                /// <summary>
 
226
                /// Gets or sets the display value of this object
 
227
                /// </summary>
 
228
                /// <remarks>
 
229
                /// This method returns a string to be used when showing the value of this object.
 
230
                /// In most cases, the Value and DisplayValue properties return the same text, but there are some cases
 
231
                /// in which DisplayValue may return a more convenient textual representation of the value, which
 
232
                /// may not be a valid target language expression.
 
233
                /// For example in C#, an enum Value includes the full enum type name (e.g. "Gtk.ResponseType.OK"),
 
234
                /// while DisplayValue only has the enum value name ("OK").
 
235
                /// </remarks>
 
236
                public string DisplayValue {
 
237
                        get { return displayValue ?? Value; }
 
238
                        set { displayValue = value; }
 
239
                }
200
240
                
 
241
                /// <summary>
 
242
                /// Sets the value of this object, using the default evaluation options
 
243
                /// </summary>
201
244
                public void SetValue (string value)
202
245
                {
203
246
                        SetValue (value, parentFrame.DebuggerSession.EvaluationOptions);
204
247
                }
205
248
                
 
249
                /// <summary>
 
250
                /// Sets the value of this object, using the specified evaluation options
 
251
                /// </summary>
 
252
                /// <param name='value'>
 
253
                /// The value
 
254
                /// </param>
 
255
                /// <param name='options'>
 
256
                /// The options
 
257
                /// </param>
 
258
                /// <exception cref='InvalidOperationException'>
 
259
                /// Is thrown if the value is read-only
 
260
                /// </exception>
206
261
                public void SetValue (string value, EvaluationOptions options)
207
262
                {
208
263
                        if (IsReadOnly || source == null)
214
269
                        }
215
270
                }
216
271
                
 
272
                /// <summary>
 
273
                /// Gets the raw value of this object
 
274
                /// </summary>
 
275
                /// <returns>
 
276
                /// The raw value.
 
277
                /// </returns>
 
278
                /// <remarks>
 
279
                /// This method can be used to get the CLR value of the object. For example, if this ObjectValue is
 
280
                /// a property of type String, this method will return the System.String value of the property.
 
281
                /// If this ObjectValue refers to an object instead of a primitive value, then a RawValue object
 
282
                /// will be returned. RawValue can be used to get and set members of an object, and to call methods.
 
283
                /// If this ObjectValue refers to an array, then a RawValueArray object will be returned.
 
284
                /// </remarks>
217
285
                public object GetRawValue ()
218
286
                {
219
287
                        return GetRawValue (parentFrame.DebuggerSession.EvaluationOptions);
220
288
                }
221
289
                
 
290
                /// <summary>
 
291
                /// Gets the raw value of this object
 
292
                /// </summary>
 
293
                /// <param name='options'>
 
294
                /// The evaluation options
 
295
                /// </param>
 
296
                /// <returns>
 
297
                /// The raw value.
 
298
                /// </returns>
 
299
                /// <remarks>
 
300
                /// This method can be used to get the CLR value of the object. For example, if this ObjectValue is
 
301
                /// a property of type String, this method will return the System.String value of the property.
 
302
                /// If this ObjectValue refers to an object instead of a primitive value, then a RawValue object
 
303
                /// will be returned. RawValue can be used to get and set members of an object, and to call methods.
 
304
                /// If this ObjectValue refers to an array, then a RawValueArray object will be returned.
 
305
                /// </remarks>
222
306
                public object GetRawValue (EvaluationOptions options)
223
307
                {
224
308
                        object res = source.GetRawValue (path, options);
228
312
                        return res;
229
313
                }
230
314
                
 
315
                /// <summary>
 
316
                /// Sets the raw value of this object
 
317
                /// </summary>
 
318
                /// <param name='value'>
 
319
                /// The value
 
320
                /// </param>
 
321
                /// <remarks>
 
322
                /// The provided value can be a primitive type, a RawValue object or a RawValueArray object.
 
323
                /// </remarks>
231
324
                public void SetRawValue (object value)
232
325
                {
233
326
                        SetRawValue (value, parentFrame.DebuggerSession.EvaluationOptions);
234
327
                }
235
328
                
 
329
                /// <summary>
 
330
                /// Sets the raw value of this object
 
331
                /// </summary>
 
332
                /// <param name='value'>
 
333
                /// The value
 
334
                /// </param>
 
335
                /// <param name='options'>
 
336
                /// The evaluation options
 
337
                /// </param>
 
338
                /// <remarks>
 
339
                /// The provided value can be a primitive type, a RawValue object or a RawValueArray object.
 
340
                /// </remarks>
236
341
                public void SetRawValue (object value, EvaluationOptions options)
237
342
                {
238
343
                        source.SetRawValue (path, value, options);
239
344
                }
240
345
                
241
 
                public string DisplayValue {
242
 
                        get { return displayValue ?? Value; }
243
 
                        set { displayValue = value; }
244
 
                }
245
 
                
 
346
                /// <summary>
 
347
                /// Full name of the type of the object
 
348
                /// </summary>
246
349
                public string TypeName {
247
350
                        get { return typeName; }
248
351
                        set { typeName = value; }
249
352
                }
250
353
                
251
354
                /// <summary>
252
 
                /// The expression to concatenate to a parent expression to get this child
253
 
                /// (for example ".foo" if this object represents a "foo" field of an object
 
355
                /// Gets or sets the child selector.
254
356
                /// </summary>
 
357
                /// <remarks>
 
358
                /// The child selector is an expression which can be concatenated to a parent expression to get this child.
 
359
                /// For example, if this object is a reference to a field named 'foo' of an object, the child
 
360
                /// selector is '.foo'.
 
361
                /// </remarks>
255
362
                public string ChildSelector {
256
363
                        get {
257
364
                                if (childSelector != null)
264
371
                        set { childSelector = value; }
265
372
                }
266
373
                
 
374
                /// <summary>
 
375
                /// Gets a value indicating whether this object has children.
 
376
                /// </summary>
 
377
                /// <value>
 
378
                /// <c>true</c> if this instance has children; otherwise, <c>false</c>.
 
379
                /// </value>
267
380
                public bool HasChildren {
268
381
                        get {
269
382
                                if (IsEvaluating)
280
393
                                        return false;
281
394
                        }
282
395
                }
283
 
                
 
396
 
 
397
                /// <summary>
 
398
                /// Gets a child value
 
399
                /// </summary>
 
400
                /// <returns>
 
401
                /// The child.
 
402
                /// </returns>
 
403
                /// <param name='name'>
 
404
                /// Name of the member
 
405
                /// </param>
 
406
                /// <remarks>
 
407
                /// This method can be used to get a member of an object (such as a field or property)
 
408
                /// </remarks>
284
409
                public ObjectValue GetChild (string name)
285
410
                {
286
411
                        return GetChild (name, parentFrame.DebuggerSession.EvaluationOptions);
287
412
                }
288
413
                
 
414
                /// <summary>
 
415
                /// Gets a child value
 
416
                /// </summary>
 
417
                /// <returns>
 
418
                /// The child.
 
419
                /// </returns>
 
420
                /// <param name='name'>
 
421
                /// Name of the member
 
422
                /// </param>
 
423
                /// <param name='options'>
 
424
                /// Options to be used to evaluate the child
 
425
                /// </param>
 
426
                /// <remarks>
 
427
                /// This method can be used to get a member of an object (such as a field or property)
 
428
                /// </remarks>
289
429
                public ObjectValue GetChild (string name, EvaluationOptions options)
290
430
                {
291
431
                        if (IsArray)
295
435
                        
296
436
                        if (children == null) {
297
437
                                children = new List<ObjectValue> ();
298
 
                                try {
299
 
                                        ObjectValue[] cs = source.GetChildren (path, -1, -1, options);
300
 
                                        ConnectCallbacks (parentFrame, cs);
301
 
                                        children.AddRange (cs);
302
 
                                } catch (Exception ex) {
303
 
                                        children = null;
304
 
                                        return CreateFatalError ("", ex.Message, ObjectValueFlags.ReadOnly);
 
438
                                if (source != null) {
 
439
                                        try {
 
440
                                                ObjectValue[] cs = source.GetChildren (path, -1, -1, options);
 
441
                                                ConnectCallbacks (parentFrame, cs);
 
442
                                                children.AddRange (cs);
 
443
                                        } catch (Exception ex) {
 
444
                                                children = null;
 
445
                                                return CreateFatalError ("", ex.Message, ObjectValueFlags.ReadOnly);
 
446
                                        }
305
447
                                }
306
448
                        }
307
449
                        foreach (ObjectValue ob in children)
310
452
                        return null;
311
453
                }
312
454
                
 
455
                /// <summary>
 
456
                /// Gets all children of the object
 
457
                /// </summary>
 
458
                /// <returns>
 
459
                /// An array of all child values
 
460
                /// </returns>
313
461
                public ObjectValue[] GetAllChildren ()
314
462
                {
315
463
                        return GetAllChildren (parentFrame.DebuggerSession.EvaluationOptions);
316
464
                }
317
465
                
 
466
                /// <summary>
 
467
                /// Gets all children of the object
 
468
                /// </summary>
 
469
                /// <returns>
 
470
                /// An array of all child values
 
471
                /// </returns>
 
472
                /// <param name='options'>
 
473
                /// Options to be used to evaluate the children
 
474
                /// </param>
318
475
                public ObjectValue[] GetAllChildren (EvaluationOptions options)
319
476
                {
320
477
                        if (IsEvaluating)
326
483
                        } else {
327
484
                                if (children == null) {
328
485
                                        children = new List<ObjectValue> ();
329
 
                                        try {
330
 
                                                ObjectValue[] cs = source.GetChildren (path, -1, -1, options);
331
 
                                                ConnectCallbacks (parentFrame, cs);
332
 
                                                children.AddRange (cs);
333
 
                                        } catch (Exception ex) {
334
 
                                                Console.WriteLine (ex);
335
 
                                                children.Add (CreateFatalError ("", ex.Message, ObjectValueFlags.ReadOnly));
 
486
                                        if (source != null) {
 
487
                                                try {
 
488
                                                        ObjectValue[] cs = source.GetChildren (path, -1, -1, options);
 
489
                                                        ConnectCallbacks (parentFrame, cs);
 
490
                                                        children.AddRange (cs);
 
491
                                                } catch (Exception ex) {
 
492
                                                        if (parentFrame != null)
 
493
                                                                parentFrame.DebuggerSession.OnDebuggerOutput( true, ex.ToString());
 
494
                                                        children.Add (CreateFatalError ("", ex.Message, ObjectValueFlags.ReadOnly));
 
495
                                                }
336
496
                                        }
337
497
                                }
338
498
                                return children.ToArray ();
339
499
                        }
340
500
                }
341
501
                
 
502
                /// <summary>
 
503
                /// Gets an item of an array
 
504
                /// </summary>
 
505
                /// <returns>
 
506
                /// The array item.
 
507
                /// </returns>
 
508
                /// <param name='index'>
 
509
                /// Item index
 
510
                /// </param>
 
511
                /// <exception cref='InvalidOperationException'>
 
512
                /// Is thrown if this object is not an array (IsArray returns false)
 
513
                /// </exception>
342
514
                public ObjectValue GetArrayItem (int index)
343
515
                {
344
516
                        return GetArrayItem (index, parentFrame.DebuggerSession.EvaluationOptions);
345
517
                }
346
518
                
 
519
                /// <summary>
 
520
                /// Gets an item of an array
 
521
                /// </summary>
 
522
                /// <returns>
 
523
                /// The array item.
 
524
                /// </returns>
 
525
                /// <param name='index'>
 
526
                /// Item index
 
527
                /// </param>
 
528
                /// <param name='options'>
 
529
                /// Options to be used to evaluate the item
 
530
                /// </param>
 
531
                /// <exception cref='InvalidOperationException'>
 
532
                /// Is thrown if this object is not an array (IsArray returns false)
 
533
                /// </exception>
347
534
                public ObjectValue GetArrayItem (int index, EvaluationOptions options)
348
535
                {
349
536
                        if (!IsArray)
368
555
                        return children [index];
369
556
                }
370
557
                
 
558
                /// <summary>
 
559
                /// Gets the number of items of an array
 
560
                /// </summary>
 
561
                /// <exception cref='InvalidOperationException'>
 
562
                /// Is thrown if this object is not an array (IsArray returns false)
 
563
                /// </exception>
371
564
                public int ArrayCount {
372
565
                        get {
373
566
                                if (!IsArray)
439
632
                        }
440
633
                }
441
634
                
 
635
                /// <summary>
 
636
                /// Refreshes the value of this object
 
637
                /// </summary>
 
638
                /// <remarks>
 
639
                /// This method can be called to get a more up-to-date value for this object.
 
640
                /// </remarks>
442
641
                public void Refresh ()
443
642
                {
444
643
                        Refresh (parentFrame.DebuggerSession.EvaluationOptions);
445
644
                }
446
645
                
 
646
                /// <summary>
 
647
                /// Refreshes the value of this object
 
648
                /// </summary>
 
649
                /// <remarks>
 
650
                /// This method can be called to get a more up-to-date value for this object.
 
651
                /// </remarks>
447
652
                public void Refresh (EvaluationOptions options)
448
653
                {
449
654
                        if (!CanRefresh)
451
656
                        ObjectValue val = source.GetValue (path, options);
452
657
                        UpdateFrom (val, false);
453
658
                }
454
 
                
 
659
 
 
660
                /// <summary>
 
661
                /// Gets a wait handle which can be used to wait for the evaluation of this object to end
 
662
                /// </summary>
 
663
                /// <value>
 
664
                /// The wait handle.
 
665
                /// </value>
455
666
                public WaitHandle WaitHandle {
456
667
                        get {
457
668
                                lock (this) {