2008-01-10 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / System.Configuration.Install / System.Configuration.Install / Installer.cs
1 // System.Configuration.Install.Installer.cs
2 //
3 // Author:
4 //      Alejandro Sánchez Acosta  <raciel@es.gnu.org>
5 //
6 // Alejandro Sánchez Acosta
7 // 
8
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 using System.Collections;
31 using System.ComponentModel;
32 using System.ComponentModel.Design;
33
34 namespace System.Configuration.Install
35 {
36         [DefaultEvent("AfterInstall")]
37         public class Installer : Component
38         {
39                 private InstallContext context;
40                 private string helptext;
41                 private InstallerCollection installers;
42                 internal Installer parent;
43                 
44                 public Installer () {
45                 }
46
47                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
48                 [BrowsableAttribute(false)]
49                 public InstallContext Context {
50                         get {
51                                 return context;
52                         }
53                         
54                         set {
55                                 context = value;
56                         }
57                 }
58
59                 public virtual string HelpText {
60                         get {
61                                 return helptext;
62                         }
63                 }
64
65                 public InstallerCollection Installers {
66                         get {
67                                 return installers;
68                         }
69                 }
70
71                 public Installer Parent {
72                         get {
73                                 return parent;
74                         }
75                         
76                         set {
77                                 parent = value;
78                         }
79                 }
80                 
81                 public virtual void Commit (IDictionary savedState) 
82                 {
83                 }
84
85                 public virtual void Install (IDictionary stateSaver)
86                 {
87                 }
88
89                 protected virtual void OnAfterInstall (IDictionary savedState)
90                 {
91                         if (AfterInstall != null)
92                                 AfterInstall (this, new InstallEventArgs (savedState));
93                 }
94                 
95                 protected virtual void OnAfterRollback (IDictionary savedState)
96                 {
97                         if (AfterRollback != null)
98                                 AfterRollback (this, new InstallEventArgs (savedState));
99                 }
100
101                 protected virtual void OnAfterUninstall (IDictionary savedState)
102                 {
103                         if (AfterUninstall != null)
104                                 AfterUninstall (this, new InstallEventArgs (savedState));
105                 }
106                 
107                 protected virtual void OnBeforeInstall (IDictionary savedState)
108                 {
109                         if (BeforeInstall != null)
110                                 BeforeInstall (this, new InstallEventArgs (savedState));
111                 }
112                 
113                 protected virtual void OnBeforeRollback (IDictionary savedState)
114                 {
115                         if (BeforeRollback != null)
116                                 BeforeRollback (this, new InstallEventArgs (savedState));
117                 }
118
119                 protected virtual void OnBeforeUninstall (IDictionary savedState)
120                 {
121                         if (BeforeUninstall != null)
122                                 BeforeUninstall (this, new InstallEventArgs (savedState));
123                 }
124                 
125                 protected virtual void OnCommitted (IDictionary savedState)
126                 {
127                         if (Committed != null)
128                                 Committed (this, new InstallEventArgs (savedState));
129                 }
130                 
131                 protected virtual void OnCommitting (IDictionary savedState)
132                 {
133                         if (Committing != null)
134                                 Committing (this, new InstallEventArgs (savedState));
135                 }
136                 
137                 public virtual void Rollback (IDictionary savedState)
138                 {
139                 }
140
141                 public virtual void Uninstall (IDictionary savedState)
142                 {
143                 }
144                 
145                 public event InstallEventHandler AfterInstall;
146
147                 public event InstallEventHandler AfterRollback;
148
149                 public event InstallEventHandler AfterUninstall;
150
151                 public event InstallEventHandler BeforeInstall;
152
153                 public event InstallEventHandler BeforeRollback;
154                 
155                 public event InstallEventHandler BeforeUninstall;
156
157                 public event InstallEventHandler Committed;
158
159                 public event InstallEventHandler Committing;            
160         }
161 }