The Labs \ Source Viewer \ SSCLI \ System.CodeDom \ CodeStatementCollection

  1. // ------------------------------------------------------------------------------
  2. // <copyright file="CodeStatementCollection.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. namespace System.CodeDom
  17. {
  18.     using System;
  19.     using System.Collections;
  20.     using System.Runtime.InteropServices;
  21.    
  22.    
  23.     /// <devdoc>
  24.     /// <para>
  25.     /// A collection that stores <see cref='System.CodeDom.CodeStatement'/> objects.
  26.     /// </para>
  27.     /// </devdoc>
  28.     [ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable()]
  29.     public class CodeStatementCollection : CollectionBase
  30.     {
  31.        
  32.         /// <devdoc>
  33.         /// <para>
  34.         /// Initializes a new instance of <see cref='System.CodeDom.CodeStatementCollection'/>.
  35.         /// </para>
  36.         /// </devdoc>
  37.         public CodeStatementCollection()
  38.         {
  39.         }
  40.        
  41.         /// <devdoc>
  42.         /// <para>
  43.         /// Initializes a new instance of <see cref='System.CodeDom.CodeStatementCollection'/> based on another <see cref='System.CodeDom.CodeStatementCollection'/>.
  44.         /// </para>
  45.         /// </devdoc>
  46.         public CodeStatementCollection(CodeStatementCollection value)
  47.         {
  48.             this.AddRange(value);
  49.         }
  50.        
  51.         /// <devdoc>
  52.         /// <para>
  53.         /// Initializes a new instance of <see cref='System.CodeDom.CodeStatementCollection'/> containing any array of <see cref='System.CodeDom.CodeStatement'/> objects.
  54.         /// </para>
  55.         /// </devdoc>
  56.         public CodeStatementCollection(CodeStatement[] value)
  57.         {
  58.             this.AddRange(value);
  59.         }
  60.        
  61.         /// <devdoc>
  62.         /// <para>Represents the entry at the specified index of the <see cref='System.CodeDom.CodeStatement'/>.</para>
  63.         /// </devdoc>
  64.         public CodeStatement this[int index]
  65.         {
  66.             get { return ((CodeStatement)(List[index])); }
  67.             set { List[index] = value; }
  68.         }
  69.        
  70.         /// <devdoc>
  71.         /// <para>Adds a <see cref='System.CodeDom.CodeStatement'/> with the specified value to the
  72.         /// <see cref='System.CodeDom.CodeStatementCollection'/> .</para>
  73.         /// </devdoc>
  74.         public int Add(CodeStatement value)
  75.         {
  76.             return List.Add(value);
  77.         }
  78.        
  79.         /// <devdoc>
  80.         /// <para>[To be supplied.]</para>
  81.         /// </devdoc>
  82.         public int Add(CodeExpression value)
  83.         {
  84.             return Add(new CodeExpressionStatement(value));
  85.         }
  86.        
  87.        
  88.         /// <devdoc>
  89.         /// <para>Copies the elements of an array to the end of the <see cref='System.CodeDom.CodeStatementCollection'/>.</para>
  90.         /// </devdoc>
  91.         public void AddRange(CodeStatement[] value)
  92.         {
  93.             if (value == null) {
  94.                 throw new ArgumentNullException("value");
  95.             }
  96.             for (int i = 0; ((i) < (value.Length)); i = ((i)+(1))) {
  97.                 this.Add(value[i]);
  98.             }
  99.         }
  100.        
  101.         /// <devdoc>
  102.         /// <para>
  103.         /// Adds the contents of another <see cref='System.CodeDom.CodeStatementCollection'/> to the end of the collection.
  104.         /// </para>
  105.         /// </devdoc>
  106.         public void AddRange(CodeStatementCollection value)
  107.         {
  108.             if (value == null) {
  109.                 throw new ArgumentNullException("value");
  110.             }
  111.             int currentCount = value.Count;
  112.             for (int i = 0; i < currentCount; i = ((i)+(1))) {
  113.                 this.Add(value[i]);
  114.             }
  115.         }
  116.        
  117.         /// <devdoc>
  118.         /// <para>Gets a value indicating whether the
  119.         /// <see cref='System.CodeDom.CodeStatementCollection'/> contains the specified <see cref='System.CodeDom.CodeStatement'/>.</para>
  120.         /// </devdoc>
  121.         public bool Contains(CodeStatement value)
  122.         {
  123.             return List.Contains(value);
  124.         }
  125.        
  126.         /// <devdoc>
  127.         /// <para>Copies the <see cref='System.CodeDom.CodeStatementCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the
  128.         /// specified index.</para>
  129.         /// </devdoc>
  130.         public void CopyTo(CodeStatement[] array, int index)
  131.         {
  132.             List.CopyTo(array, index);
  133.         }
  134.        
  135.         /// <devdoc>
  136.         /// <para>Returns the index of a <see cref='System.CodeDom.CodeStatement'/> in
  137.         /// the <see cref='System.CodeDom.CodeStatementCollection'/> .</para>
  138.         /// </devdoc>
  139.         public int IndexOf(CodeStatement value)
  140.         {
  141.             return List.IndexOf(value);
  142.         }
  143.        
  144.         /// <devdoc>
  145.         /// <para>Inserts a <see cref='System.CodeDom.CodeStatement'/> into the <see cref='System.CodeDom.CodeStatementCollection'/> at the specified index.</para>
  146.         /// </devdoc>
  147.         public void Insert(int index, CodeStatement value)
  148.         {
  149.             List.Insert(index, value);
  150.         }
  151.        
  152.         /// <devdoc>
  153.         /// <para> Removes a specific <see cref='System.CodeDom.CodeStatement'/> from the
  154.         /// <see cref='System.CodeDom.CodeStatementCollection'/> .</para>
  155.         /// </devdoc>
  156.         public void Remove(CodeStatement value)
  157.         {
  158.             List.Remove(value);
  159.         }
  160.     }
  161. }

Developer Fusion