Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System / compmod / system / codedom / CodeAttachEventStatement.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="CodeAttachEventStatement.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 event attach statement.
20     ///    </para>
21     /// </devdoc>
22     [
23         ClassInterface(ClassInterfaceType.AutoDispatch),
24         ComVisible(true),
25         Serializable,
26     ]
27     public class CodeAttachEventStatement : CodeStatement {
28         private CodeEventReferenceExpression eventRef;
29         private CodeExpression listener;
30
31         /// <devdoc>
32         ///    <para>
33         ///       Initializes a new instance of <see cref='System.CodeDom.CodeAttachEventStatement'/>.
34         ///    </para>
35         /// </devdoc>
36         public CodeAttachEventStatement() {
37         }
38
39         /// <devdoc>
40         ///    <para>
41         ///       Initializes a new instance of the <see cref='System.CodeDom.CodeAttachEventStatement'/> class using the specified arguments.
42         ///    </para>
43         /// </devdoc>
44         public CodeAttachEventStatement(CodeEventReferenceExpression eventRef, CodeExpression listener) {
45             this.eventRef = eventRef;
46             this.listener = listener;
47         }
48
49         /// <devdoc>
50         ///    <para>[To be supplied.]</para>
51         /// </devdoc>
52         public CodeAttachEventStatement(CodeExpression targetObject, string eventName, CodeExpression listener) {
53             this.eventRef = new CodeEventReferenceExpression(targetObject, eventName);
54             this.listener = listener;
55         }
56
57         /// <devdoc>
58         ///    <para>
59         ///       The event to attach a listener to.
60         ///    </para>
61         /// </devdoc>
62         public CodeEventReferenceExpression Event {
63             get {
64                 if (eventRef == null) {
65                     return new CodeEventReferenceExpression();
66                 }
67                 return eventRef;
68             }
69             set {
70                 eventRef = value;
71             }
72         }
73
74         /// <devdoc>
75         ///    <para>
76         ///       The new listener.
77         ///    </para>
78         /// </devdoc>
79         public CodeExpression Listener {
80             get {
81                 return listener;
82             }
83             set {
84                 listener = value;
85             }
86         }
87     }
88 }