The Labs \ Source Viewer \ SSCLI \ System.Collections.Generic \ Mscorlib_CollectionDebugView

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

Developer Fusion