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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="CodeArrayCreateExpression.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. namespace System.CodeDom
  16. {
  17.    
  18.     using System.Diagnostics;
  19.     using System;
  20.     using Microsoft.Win32;
  21.     using System.Collections;
  22.     using System.Runtime.InteropServices;
  23.    
  24.     /// <devdoc>
  25.     /// <para> Represents
  26.     /// an expression that creates an array.</para>
  27.     /// </devdoc>
  28.     [ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable()]
  29.     public class CodeArrayCreateExpression : CodeExpression
  30.     {
  31.         private CodeTypeReference createType;
  32.         private CodeExpressionCollection initializers = new CodeExpressionCollection();
  33.         private CodeExpression sizeExpression;
  34.         private int size = 0;
  35.        
  36.         /// <devdoc>
  37.         /// <para>
  38.         /// Initializes a new instance of <see cref='System.CodeDom.CodeArrayCreateExpression'/>.
  39.         /// </para>
  40.         /// </devdoc>
  41.         public CodeArrayCreateExpression()
  42.         {
  43.         }
  44.        
  45.         /// <devdoc>
  46.         /// <para>
  47.         /// Initializes a new instance of <see cref='System.CodeDom.CodeArrayCreateExpression'/> with the specified
  48.         /// array type and initializers.
  49.         /// </para>
  50.         /// </devdoc>
  51.         public CodeArrayCreateExpression(CodeTypeReference createType, params CodeExpression[] initializers)
  52.         {
  53.             this.createType = createType;
  54.             this.initializers.AddRange(initializers);
  55.         }
  56.        
  57.         /// <devdoc>
  58.         /// <para>[To be supplied.]</para>
  59.         /// </devdoc>
  60.         public CodeArrayCreateExpression(string createType, params CodeExpression[] initializers)
  61.         {
  62.             this.createType = new CodeTypeReference(createType);
  63.             this.initializers.AddRange(initializers);
  64.         }
  65.        
  66.         /// <devdoc>
  67.         /// <para>[To be supplied.]</para>
  68.         /// </devdoc>
  69.         public CodeArrayCreateExpression(Type createType, params CodeExpression[] initializers)
  70.         {
  71.             this.createType = new CodeTypeReference(createType);
  72.             this.initializers.AddRange(initializers);
  73.         }
  74.        
  75.         /// <devdoc>
  76.         /// <para>
  77.         /// Initializes a new instance of <see cref='System.CodeDom.CodeArrayCreateExpression'/>. with the specified array
  78.         /// type and size.
  79.         /// </para>
  80.         /// </devdoc>
  81.         public CodeArrayCreateExpression(CodeTypeReference createType, int size)
  82.         {
  83.             this.createType = createType;
  84.             this.size = size;
  85.         }
  86.        
  87.         /// <devdoc>
  88.         /// <para>[To be supplied.]</para>
  89.         /// </devdoc>
  90.         public CodeArrayCreateExpression(string createType, int size)
  91.         {
  92.             this.createType = new CodeTypeReference(createType);
  93.             this.size = size;
  94.         }
  95.        
  96.         /// <devdoc>
  97.         /// <para>[To be supplied.]</para>
  98.         /// </devdoc>
  99.         public CodeArrayCreateExpression(Type createType, int size)
  100.         {
  101.             this.createType = new CodeTypeReference(createType);
  102.             this.size = size;
  103.         }
  104.        
  105.         /// <devdoc>
  106.         /// <para>
  107.         /// Initializes a new instance of <see cref='System.CodeDom.CodeArrayCreateExpression'/>. with the specified array
  108.         /// type and size.
  109.         /// </para>
  110.         /// </devdoc>
  111.         public CodeArrayCreateExpression(CodeTypeReference createType, CodeExpression size)
  112.         {
  113.             this.createType = createType;
  114.             this.sizeExpression = size;
  115.         }
  116.        
  117.         /// <devdoc>
  118.         /// <para>[To be supplied.]</para>
  119.         /// </devdoc>
  120.         public CodeArrayCreateExpression(string createType, CodeExpression size)
  121.         {
  122.             this.createType = new CodeTypeReference(createType);
  123.             this.sizeExpression = size;
  124.         }
  125.        
  126.         /// <devdoc>
  127.         /// <para>[To be supplied.]</para>
  128.         /// </devdoc>
  129.         public CodeArrayCreateExpression(Type createType, CodeExpression size)
  130.         {
  131.             this.createType = new CodeTypeReference(createType);
  132.             this.sizeExpression = size;
  133.         }
  134.        
  135.         /// <devdoc>
  136.         /// <para>
  137.         /// Gets or sets
  138.         /// the type of the array to create.
  139.         /// </para>
  140.         /// </devdoc>
  141.         public CodeTypeReference CreateType {
  142.             get {
  143.                 if (createType == null) {
  144.                     createType = new CodeTypeReference("");
  145.                 }
  146.                 return createType;
  147.             }
  148.             set { createType = value; }
  149.         }
  150.        
  151.         /// <devdoc>
  152.         /// <para>
  153.         /// Gets or sets
  154.         /// the initializers to initialize the array with.
  155.         /// </para>
  156.         /// </devdoc>
  157.         public CodeExpressionCollection Initializers {
  158.             get { return initializers; }
  159.         }
  160.        
  161.         /// <devdoc>
  162.         /// <para>
  163.         /// Gets or sets
  164.         /// the size of the array.
  165.         /// </para>
  166.         /// </devdoc>
  167.         public int Size {
  168.             get { return size; }
  169.             set { size = value; }
  170.         }
  171.        
  172.         /// <devdoc>
  173.         /// <para>Gets or sets the size of the array.</para>
  174.         /// </devdoc>
  175.         public CodeExpression SizeExpression {
  176.             get { return sizeExpression; }
  177.             set { sizeExpression = value; }
  178.         }
  179.     }
  180. }

Developer Fusion