Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
CollectionDebugView.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections;
5 using System.Collections.Generic;
6 using System.Diagnostics;
7 using System.Linq;
9 
10 namespace SiliconStudio.Core.Diagnostics
11 {
12  /// <summary>
13  /// Use this class to provide a debug output in Visual Studio debugger.
14  /// </summary>
15  public class CollectionDebugView
16  {
17  private readonly IEnumerable collection;
18 
19  public CollectionDebugView(IEnumerable collection)
20  {
21  if (collection == null)
22  throw new ArgumentNullException("collection");
23  this.collection = collection;
24  }
25 
26  [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
27  public object[] Items
28  {
29  get
30  {
31  return collection.Cast<object>().ToArray();
32  }
33  }
34  }
35 
36  /// <summary>
37  /// Use this class to provide a debug output in Visual Studio debugger.
38  /// </summary>
39  public class CollectionDebugView<T>
40  {
41  private readonly ICollection<T> collection;
42 
44  {
45  if (collection == null)
46  throw new ArgumentNullException("collection");
47  this.collection = collection;
48  }
49 
50  [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
51  public T[] Items
52  {
53  get
54  {
55  T[] array = new T[this.collection.Count];
56  this.collection.CopyTo(array, 0);
57  return array;
58  }
59  }
60  }
61 }
System.Collections.ICollection ICollection
Use this class to provide a debug output in Visual Studio debugger.