The Labs \ Source Viewer \ SSCLI \ System.Collections \ ReadOnlyCollectionBase

  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. namespace System.Collections
  18. {
  19.    
  20.     using System;
  21.    
  22.     // Useful base class for typed readonly collections where items derive from object
  23.     [Serializable()]
  24.     [System.Runtime.InteropServices.ComVisible(true)]
  25.     public abstract class ReadOnlyCollectionBase : ICollection
  26.     {
  27.         ArrayList list;
  28.        
  29.         protected ArrayList InnerList {
  30.             get {
  31.                 if (list == null)
  32.                     list = new ArrayList();
  33.                 return list;
  34.             }
  35.         }
  36.        
  37.         public virtual int Count {
  38.             get { return InnerList.Count; }
  39.         }
  40.        
  41.         bool ICollection.IsSynchronized {
  42.             get { return InnerList.IsSynchronized; }
  43.         }
  44.        
  45.         object ICollection.SyncRoot {
  46.             get { return InnerList.SyncRoot; }
  47.         }
  48.        
  49.         void ICollection.CopyTo(Array array, int index)
  50.         {
  51.             InnerList.CopyTo(array, index);
  52.         }
  53.        
  54.         public virtual IEnumerator GetEnumerator()
  55.         {
  56.             return InnerList.GetEnumerator();
  57.         }
  58.     }
  59.    
  60. }

Developer Fusion