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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="CodeCastExpression.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
  27.     /// type cast expression.
  28.     /// </para>
  29.     /// </devdoc>
  30.     [ClassInterface(ClassInterfaceType.AutoDispatch), ComVisible(true), Serializable()]
  31.     public class CodeCastExpression : CodeExpression
  32.     {
  33.         private CodeTypeReference targetType;
  34.         private CodeExpression expression;
  35.        
  36.         /// <devdoc>
  37.         /// <para>
  38.         /// Initializes a new instance of <see cref='System.CodeDom.CodeCastExpression'/>.
  39.         /// </para>
  40.         /// </devdoc>
  41.         public CodeCastExpression()
  42.         {
  43.         }
  44.        
  45.         /// <devdoc>
  46.         /// <para>
  47.         /// Initializes a new instance of <see cref='System.CodeDom.CodeCastExpression'/> using the specified
  48.         /// parameters.
  49.         /// </para>
  50.         /// </devdoc>
  51.         public CodeCastExpression(CodeTypeReference targetType, CodeExpression expression)
  52.         {
  53.             TargetType = targetType;
  54.             Expression = expression;
  55.         }
  56.        
  57.         /// <devdoc>
  58.         /// <para>[To be supplied.]</para>
  59.         /// </devdoc>
  60.         public CodeCastExpression(string targetType, CodeExpression expression)
  61.         {
  62.             TargetType = new CodeTypeReference(targetType);
  63.             Expression = expression;
  64.         }
  65.        
  66.         /// <devdoc>
  67.         /// <para>[To be supplied.]</para>
  68.         /// </devdoc>
  69.         public CodeCastExpression(Type targetType, CodeExpression expression)
  70.         {
  71.             TargetType = new CodeTypeReference(targetType);
  72.             Expression = expression;
  73.         }
  74.        
  75.         /// <devdoc>
  76.         /// <para>
  77.         /// The target type of the cast.
  78.         /// </para>
  79.         /// </devdoc>
  80.         public CodeTypeReference TargetType {
  81.             get {
  82.                 if (targetType == null) {
  83.                     targetType = new CodeTypeReference("");
  84.                 }
  85.                 return targetType;
  86.             }
  87.             set { targetType = value; }
  88.         }
  89.        
  90.         /// <devdoc>
  91.         /// <para>
  92.         /// The expression to cast.
  93.         /// </para>
  94.         /// </devdoc>
  95.         public CodeExpression Expression {
  96.             get { return expression; }
  97.             set { expression = value; }
  98.         }
  99.     }
  100. }

Developer Fusion