f136ff61794fb8322f94443ea0f28a61de2aa2fa
[mono.git] / mcs / class / referencesource / System / compmod / system / codedom / CodeCastExpression.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="CodeCastExpression.cs" company="Microsoft">
3 // 
4 // <OWNER>Microsoft</OWNER>
5 //     Copyright (c) Microsoft Corporation.  All rights reserved.
6 // </copyright>                                                                
7 //------------------------------------------------------------------------------
8
9 namespace System.CodeDom {
10
11     using System.Diagnostics;
12     using System;
13     using Microsoft.Win32;
14     using System.Collections;
15     using System.Runtime.InteropServices;
16
17     /// <devdoc>
18     ///    <para>
19     ///       Represents a
20     ///       type cast expression.
21     ///    </para>
22     /// </devdoc>
23     [
24         ClassInterface(ClassInterfaceType.AutoDispatch),
25         ComVisible(true),
26         Serializable,
27     ]
28     public class CodeCastExpression : CodeExpression {
29         private CodeTypeReference targetType;
30         private CodeExpression expression;
31
32         /// <devdoc>
33         ///    <para>
34         ///       Initializes a new instance of <see cref='System.CodeDom.CodeCastExpression'/>.
35         ///    </para>
36         /// </devdoc>
37         public CodeCastExpression() {
38         }
39
40         /// <devdoc>
41         ///    <para>
42         ///       Initializes a new instance of <see cref='System.CodeDom.CodeCastExpression'/> using the specified
43         ///       parameters.
44         ///    </para>
45         /// </devdoc>
46         public CodeCastExpression(CodeTypeReference targetType, CodeExpression expression) {
47             TargetType = targetType;
48             Expression = expression;
49         }
50
51         /// <devdoc>
52         ///    <para>[To be supplied.]</para>
53         /// </devdoc>
54         public CodeCastExpression(string targetType, CodeExpression expression) {
55             TargetType = new CodeTypeReference(targetType);
56             Expression = expression;
57         }
58
59         /// <devdoc>
60         ///    <para>[To be supplied.]</para>
61         /// </devdoc>
62         public CodeCastExpression(Type targetType, CodeExpression expression) {
63             TargetType = new CodeTypeReference(targetType);
64             Expression = expression;
65         }
66
67         /// <devdoc>
68         ///    <para>
69         ///       The target type of the cast.
70         ///    </para>
71         /// </devdoc>
72         public CodeTypeReference TargetType {
73             get {
74                 if (targetType == null) {
75                     targetType = new CodeTypeReference("");
76                 }
77                 return targetType;
78             }
79             set {
80                 targetType = value;
81             }
82         }
83
84         /// <devdoc>
85         ///    <para>
86         ///       The expression to cast.
87         ///    </para>
88         /// </devdoc>
89         public CodeExpression Expression {
90             get {
91                 return expression;
92             }
93             set {
94                 expression = value;
95             }
96         }
97     }
98 }