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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="CodeVariableDeclarationStatement.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>
  26.     /// Represents a local variable declaration.
  27.     /// </para>
  28.     /// </devdoc>
  29.     [ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable()]
  30.     public class CodeVariableDeclarationStatement : CodeStatement
  31.     {
  32.         private CodeTypeReference type;
  33.         private string name;
  34.         private CodeExpression initExpression;
  35.        
  36.         /// <devdoc>
  37.         /// <para>
  38.         /// Initializes a new instance of <see cref='System.CodeDom.CodeVariableDeclarationStatement'/>.
  39.         /// </para>
  40.         /// </devdoc>
  41.         public CodeVariableDeclarationStatement()
  42.         {
  43.         }
  44.        
  45.         /// <devdoc>
  46.         /// <para>
  47.         /// Initializes a new instance of <see cref='System.CodeDom.CodeVariableDeclarationStatement'/> using the specified type and name.
  48.         /// </para>
  49.         /// </devdoc>
  50.         public CodeVariableDeclarationStatement(CodeTypeReference type, string name)
  51.         {
  52.             Type = type;
  53.             Name = name;
  54.         }
  55.        
  56.         /// <devdoc>
  57.         /// <para>[To be supplied.]</para>
  58.         /// </devdoc>
  59.         public CodeVariableDeclarationStatement(string type, string name)
  60.         {
  61.             Type = new CodeTypeReference(type);
  62.             Name = name;
  63.         }
  64.        
  65.         /// <devdoc>
  66.         /// <para>[To be supplied.]</para>
  67.         /// </devdoc>
  68.         public CodeVariableDeclarationStatement(Type type, string name)
  69.         {
  70.             Type = new CodeTypeReference(type);
  71.             Name = name;
  72.         }
  73.        
  74.         /// <devdoc>
  75.         /// <para>
  76.         /// Initializes a new instance of <see cref='System.CodeDom.CodeVariableDeclarationStatement'/> using the specified type, name and
  77.         /// initialization expression.
  78.         /// </para>
  79.         /// </devdoc>
  80.         public CodeVariableDeclarationStatement(CodeTypeReference type, string name, CodeExpression initExpression)
  81.         {
  82.             Type = type;
  83.             Name = name;
  84.             InitExpression = initExpression;
  85.         }
  86.        
  87.         /// <devdoc>
  88.         /// <para>[To be supplied.]</para>
  89.         /// </devdoc>
  90.         public CodeVariableDeclarationStatement(string type, string name, CodeExpression initExpression)
  91.         {
  92.             Type = new CodeTypeReference(type);
  93.             Name = name;
  94.             InitExpression = initExpression;
  95.         }
  96.        
  97.         /// <devdoc>
  98.         /// <para>[To be supplied.]</para>
  99.         /// </devdoc>
  100.         public CodeVariableDeclarationStatement(Type type, string name, CodeExpression initExpression)
  101.         {
  102.             Type = new CodeTypeReference(type);
  103.             Name = name;
  104.             InitExpression = initExpression;
  105.         }
  106.        
  107.         /// <devdoc>
  108.         /// <para>
  109.         /// Gets or sets the initialization expression for the variable.
  110.         /// </para>
  111.         /// </devdoc>
  112.         public CodeExpression InitExpression {
  113.             get { return initExpression; }
  114.             set { initExpression = value; }
  115.         }
  116.        
  117.         /// <devdoc>
  118.         /// <para>
  119.         /// Gets or sets the name of the variable.
  120.         /// </para>
  121.         /// </devdoc>
  122.         public string Name {
  123.             get { return (name == null) ? string.Empty : name; }
  124.             set { name = value; }
  125.         }
  126.        
  127.         /// <devdoc>
  128.         /// <para>
  129.         /// Gets or sets the type of the variable.
  130.         /// </para>
  131.         /// </devdoc>
  132.         public CodeTypeReference Type {
  133.             get {
  134.                 if (type == null) {
  135.                     type = new CodeTypeReference("");
  136.                 }
  137.                 return type;
  138.             }
  139.             set { type = value; }
  140.         }
  141.     }
  142. }

Developer Fusion