The Labs \ Source Viewer \ SSCLI \ System.ComponentModel.Design \ DesignerCollection

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DocumentCollection.cs" company="Microsoft">
  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. // </copyright>
  14. //------------------------------------------------------------------------------
  15. /*
  16. */
  17. namespace System.ComponentModel.Design
  18. {
  19.     using Microsoft.Win32;
  20.     using System.Collections;
  21.     using System.ComponentModel;
  22.     using System.Diagnostics;
  23.     using System.Runtime.InteropServices;
  24.     using System.Security.Permissions;
  25.    
  26.     /// <devdoc>
  27.     /// <para>
  28.     /// Provides a read-only collection of documents.
  29.     /// </para>
  30.     /// </devdoc>
  31.     [HostProtection(SharedState = true)]
  32.     [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name = "FullTrust")]
  33.     [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Name = "FullTrust")]
  34.     public class DesignerCollection : ICollection
  35.     {
  36.         private IList designers;
  37.        
  38.         /// <devdoc>
  39.         /// <para>
  40.         /// Initializes a new instance of the <see cref='System.ComponentModel.Design.DesignerCollection'/> class
  41.         /// that stores an array with a pointer to each <see cref='System.ComponentModel.Design.IDesignerHost'/>
  42.         /// for each document in the collection.
  43.         /// </para>
  44.         /// </devdoc>
  45.         public DesignerCollection(IDesignerHost[] designers)
  46.         {
  47.             if (designers != null) {
  48.                 this.designers = new ArrayList(designers);
  49.             }
  50.             else {
  51.                 this.designers = new ArrayList();
  52.             }
  53.         }
  54.        
  55.         /// <devdoc>
  56.         /// <para>
  57.         /// Initializes a new instance of the <see cref='System.ComponentModel.Design.DesignerCollection'/> class
  58.         /// that stores an array with a pointer to each <see cref='System.ComponentModel.Design.IDesignerHost'/>
  59.         /// for each document in the collection.
  60.         /// </para>
  61.         /// </devdoc>
  62.         public DesignerCollection(IList designers)
  63.         {
  64.             this.designers = designers;
  65.         }
  66.        
  67.         /// <devdoc>
  68.         /// <para>Gets or
  69.         /// sets the number
  70.         /// of documents in the collection.</para>
  71.         /// </devdoc>
  72.         public int Count {
  73.             get { return designers.Count; }
  74.         }
  75.        
  76.         /// <devdoc>
  77.         /// <para> Gets
  78.         /// or sets the document at the specified index.</para>
  79.         /// </devdoc>
  80.         public virtual IDesignerHost this[int index]
  81.         {
  82.             get { return (IDesignerHost)designers[index]; }
  83.         }
  84.        
  85.         /// <devdoc>
  86.         /// <para>Creates and retrieves a new enumerator for this collection.</para>
  87.         /// </devdoc>
  88.         public IEnumerator GetEnumerator()
  89.         {
  90.             return designers.GetEnumerator();
  91.         }
  92.        
  93.         /// <internalonly/>
  94.         int ICollection.Count {
  95.             get { return Count; }
  96.         }
  97.        
  98.         /// <internalonly/>
  99.         bool ICollection.IsSynchronized {
  100.             get { return false; }
  101.         }
  102.        
  103.         /// <internalonly/>
  104.         object ICollection.SyncRoot {
  105.             get { return null; }
  106.         }
  107.        
  108.         /// <internalonly/>
  109.         void ICollection.CopyTo(Array array, int index)
  110.         {
  111.             designers.CopyTo(array, index);
  112.         }
  113.        
  114.         /// <internalonly/>
  115.         IEnumerator IEnumerable.GetEnumerator()
  116.         {
  117.             return GetEnumerator();
  118.         }
  119.     }
  120. }

Developer Fusion