-
Notifications
You must be signed in to change notification settings - Fork 12
/
DebugView.cs
52 lines (42 loc) · 1.63 KB
/
DebugView.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace Tmc {
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
internal class CollectionDebugView<T> {
private readonly ICollection<T> _collection;
public CollectionDebugView(ICollection<T> collection) {
if (collection == null) {
throw new ArgumentNullException("collection");
}
_collection = collection;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public T[] Items {
get {
var items = new T[_collection.Count];
_collection.CopyTo(items, 0);
return items;
}
}
}
internal sealed class DictionaryDebugView<TKey, TValue> {
public sealed class KeyCollectionView : CollectionDebugView<TKey> {
public KeyCollectionView(ICollection<TKey> collection) : base(collection) { }
}
public sealed class ValueCollectionView : CollectionDebugView<TValue> {
public ValueCollectionView(ICollection<TValue> collection) : base(collection) { }
}
private readonly IDictionary<TKey, TValue> _dict;
public DictionaryDebugView(IDictionary<TKey, TValue> dictionary) {
if (dictionary == null) {
throw new ArgumentNullException("dictionary");
}
_dict = dictionary;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public KeyValuePair<TKey, TValue>[] Items {
get { return _dict.ToArray(); }
}
}
}