| 1 |
// ==++== |
| 2 |
// |
| 3 |
// Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 |
// |
| 5 |
// ==--== |
| 6 |
/*============================================================================= |
| 7 |
** |
| 8 |
** |
| 9 |
** |
| 10 |
** Purpose: DebugView class for generic collections |
| 11 |
** |
| 12 |
** <OWNER>Microsoft</OWNER> |
| 13 |
** |
| 14 |
** |
| 15 |
=============================================================================*/ |
| 16 |
|
| 17 |
namespace System.Collections.Generic { |
| 18 |
using System; |
| 19 |
using System.Collections.ObjectModel; |
| 20 |
using System.Security.Permissions; |
| 21 |
using System.Diagnostics; |
| 22 |
using System.Diagnostics.Contracts; |
| 23 |
|
| 24 |
// |
| 25 |
// VS IDE can't differentiate between types with the same name from different |
| 26 |
// assembly. So we need to use different names for collection debug view for |
| 27 |
// collections in mscorlib.dll and system.dll. |
| 28 |
// |
| 29 |
internal sealed class Mscorlib_CollectionDebugView<T> { |
| 30 |
private ICollection<T> collection; |
| 31 |
|
| 32 |
public Mscorlib_CollectionDebugView(ICollection<T> collection) { |
| 33 |
if (collection == null) |
| 34 |
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); |
| 35 |
|
| 36 |
this.collection = collection; |
| 37 |
} |
| 38 |
|
| 39 |
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] |
| 40 |
public T[] Items { |
| 41 |
get { |
| 42 |
T[] items = new T[collection.Count]; |
| 43 |
collection.CopyTo(items, 0); |
| 44 |
return items; |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
internal sealed class Mscorlib_DictionaryKeyCollectionDebugView<TKey, TValue> { |
| 50 |
private ICollection<TKey> collection; |
| 51 |
|
| 52 |
public Mscorlib_DictionaryKeyCollectionDebugView(ICollection<TKey> collection) { |
| 53 |
if (collection == null) |
| 54 |
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); |
| 55 |
|
| 56 |
this.collection = collection; |
| 57 |
} |
| 58 |
|
| 59 |
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] |
| 60 |
public TKey[] Items { |
| 61 |
get { |
| 62 |
TKey[] items = new TKey[collection.Count]; |
| 63 |
collection.CopyTo(items, 0); |
| 64 |
return items; |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
internal sealed class Mscorlib_DictionaryValueCollectionDebugView<TKey, TValue> { |
| 70 |
private ICollection<TValue> collection; |
| 71 |
|
| 72 |
public Mscorlib_DictionaryValueCollectionDebugView(ICollection<TValue> collection) { |
| 73 |
if (collection == null) |
| 74 |
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); |
| 75 |
|
| 76 |
this.collection = collection; |
| 77 |
} |
| 78 |
|
| 79 |
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] |
| 80 |
public TValue[] Items { |
| 81 |
get { |
| 82 |
TValue[] items = new TValue[collection.Count]; |
| 83 |
collection.CopyTo(items, 0); |
| 84 |
return items; |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
internal sealed class Mscorlib_DictionaryDebugView<K, V> { |
| 90 |
private IDictionary<K, V> dict; |
| 91 |
|
| 92 |
public Mscorlib_DictionaryDebugView(IDictionary<K, V> dictionary) { |
| 93 |
if (dictionary == null) |
| 94 |
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.dictionary); |
| 95 |
|
| 96 |
this.dict = dictionary; |
| 97 |
} |
| 98 |
|
| 99 |
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] |
| 100 |
public KeyValuePair<K, V>[] Items { |
| 101 |
get { |
| 102 |
KeyValuePair<K, V>[] items = new KeyValuePair<K, V>[dict.Count]; |
| 103 |
dict.CopyTo(items, 0); |
| 104 |
return items; |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
internal sealed class Mscorlib_KeyedCollectionDebugView<K, T> { |
| 110 |
private KeyedCollection<K, T> kc; |
| 111 |
|
| 112 |
public Mscorlib_KeyedCollectionDebugView(KeyedCollection<K, T> keyedCollection) { |
| 113 |
if (keyedCollection == null) { |
| 114 |
throw new ArgumentNullException("keyedCollection"); |
| 115 |
} |
| 116 |
Contract.EndContractBlock(); |
| 117 |
|
| 118 |
kc = keyedCollection; |
| 119 |
} |
| 120 |
|
| 121 |
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] |
| 122 |
public T[] Items { |
| 123 |
get { |
| 124 |
T[] items = new T[kc.Count]; |
| 125 |
kc.CopyTo(items, 0); |
| 126 |
return items; |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
} |