Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System / compmod / system / codedom / CodeCatchClause.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="CodeCatchClause.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>Represents a catch exception block.</para>
19     /// </devdoc>
20     [
21         ClassInterface(ClassInterfaceType.AutoDispatch),
22         ComVisible(true),
23         Serializable,
24     ]
25     public class CodeCatchClause {
26         private CodeStatementCollection statements;
27         private CodeTypeReference catchExceptionType;
28         private string localName;
29
30         /// <devdoc>
31         ///    <para>
32         ///       Initializes an instance of <see cref='System.CodeDom.CodeCatchClause'/>.
33         ///    </para>
34         /// </devdoc>
35         public CodeCatchClause() {
36         }
37
38         /// <devdoc>
39         ///    <para>[To be supplied.]</para>
40         /// </devdoc>
41         public CodeCatchClause(string localName) {
42             this.localName = localName;
43         }
44
45         /// <devdoc>
46         ///    <para>[To be supplied.]</para>
47         /// </devdoc>
48         public CodeCatchClause(string localName, CodeTypeReference catchExceptionType) {
49             this.localName = localName;
50             this.catchExceptionType = catchExceptionType;
51         }
52
53         /// <devdoc>
54         ///    <para>[To be supplied.]</para>
55         /// </devdoc>
56         public CodeCatchClause(string localName, CodeTypeReference catchExceptionType, params CodeStatement[] statements) {
57             this.localName = localName;
58             this.catchExceptionType = catchExceptionType;
59             Statements.AddRange(statements);
60         }
61
62         /// <devdoc>
63         ///    <para>[To be supplied.]</para>
64         /// </devdoc>
65         public string LocalName {
66             get {
67                 return (localName == null) ? string.Empty: localName;
68             }
69             set {
70                 localName = value;
71             }
72         }
73
74         /// <devdoc>
75         ///    <para>[To be supplied.]</para>
76         /// </devdoc>
77         public CodeTypeReference CatchExceptionType {
78             get {
79                 if (catchExceptionType == null) {
80                     catchExceptionType = new CodeTypeReference(typeof(System.Exception));
81                 }
82                 return catchExceptionType;
83             }
84             set {
85                 catchExceptionType = value;
86             }
87         }
88
89         /// <devdoc>
90         ///    <para>
91         ///       Gets or sets the statements within the clause.
92         ///    </para>
93         /// </devdoc>
94         public CodeStatementCollection Statements {
95             get {
96                 if (statements == null) {
97                     statements = new CodeStatementCollection();
98                 }
99                 return statements;
100             }
101         }
102     }
103 }