New test.
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / EventSource.cs
1 //
2 // EventSource.cs: Implements IEventSource.
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 // 
7 // (C) 2005 Marek Sieradzki
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 #if NET_2_0
29
30 using Microsoft.Build.Framework;
31
32 namespace Microsoft.Build.BuildEngine {
33         internal class EventSource : IEventSource {
34                 
35                 AnyEventHandler                 anyEventRaised;
36                 BuildFinishedEventHandler       buildFinished;
37                 BuildStartedEventHandler        buildStarted;
38                 CustomBuildEventHandler         customEventRaised;
39                 BuildErrorEventHandler          errorRaised;
40                 BuildMessageEventHandler        messageRaised;
41                 ProjectFinishedEventHandler     projectFinished;
42                 ProjectStartedEventHandler      projectStarted;
43                 BuildStatusEventHandler         statusEventRaised;
44                 TargetFinishedEventHandler      targetFinished;
45                 TargetStartedEventHandler       targetStarted;
46                 TaskFinishedEventHandler        taskFinished;
47                 TaskStartedEventHandler         taskStarted;
48                 BuildWarningEventHandler        warningRaised;
49                 bool                            onlyLogCriticalEvents;
50
51                 public EventSource ()
52                 {
53                         this.onlyLogCriticalEvents = false;
54                 }
55                 
56                 public void FireCustomEventRaised (object sender, CustomBuildEventArgs cbea)
57                 {
58                         if (customEventRaised != null)
59                                 customEventRaised (sender, cbea);
60                 }
61                 public void FireErrorRaised (object sender, BuildErrorEventArgs beea)
62                 {
63                         if (errorRaised != null)
64                                 errorRaised (sender, beea);
65                 }
66                 public void FireMessageRaised (object sender, BuildMessageEventArgs bmea)
67                 {
68                         if (messageRaised != null)
69                                 messageRaised (sender, bmea);
70                 }
71                 public void FireWarningRaised (object sender, BuildWarningEventArgs bwea)
72                 {
73                         if (warningRaised != null)
74                                 warningRaised (sender, bwea);
75                 }
76                 
77                 public void FireTargetStarted (object sender, TargetStartedEventArgs tsea)
78                 {
79                         if (targetStarted != null)
80                                 targetStarted (sender, tsea);
81                 }
82                 
83                 public void FireTargetFinished (object sender, TargetFinishedEventArgs tfea)
84                 {
85                         if (targetFinished != null)
86                                 targetFinished (sender, tfea);
87                 }
88                 
89                 public void FireBuildStarted (object sender, BuildStartedEventArgs bsea)
90                 {
91                         if (buildStarted != null)
92                                 buildStarted (sender, bsea);
93                 }
94                 
95                 public void FireBuildFinished (object sender, BuildFinishedEventArgs bfea)
96                 {
97                         if (buildFinished != null)
98                                 buildFinished (sender, bfea);
99                 }
100                 
101                 public void FireProjectStarted (object sender, ProjectStartedEventArgs psea)
102                 {
103                         if (projectStarted != null)
104                                 projectStarted (sender, psea);
105                 }
106                 
107                 public void FireProjectFinished (object sender, ProjectFinishedEventArgs pfea)
108                 {
109                         if (projectFinished != null)
110                                 projectFinished (sender, pfea);
111                 }
112                 
113                 public void FireTaskStarted (object sender, TaskStartedEventArgs tsea)
114                 {
115                         if (taskStarted != null)
116                                 taskStarted (sender, tsea);
117                 }
118                 
119                 public void FireTaskFinished (object sender, TaskFinishedEventArgs tfea)
120                 {
121                         if (taskFinished != null)
122                                 taskFinished (sender, tfea);
123                 }
124
125                 public event AnyEventHandler AnyEventRaised {
126                         add {
127                                 lock (this)
128                                         anyEventRaised += value;
129                         }
130                         remove {
131                                 lock (this)
132                                         anyEventRaised -= value;
133                         }
134                 }
135                 
136                 public event BuildFinishedEventHandler BuildFinished {
137                         add {
138                                 lock (this)
139                                         buildFinished += value;
140                         }
141                         remove {
142                                 lock (this)
143                                         buildFinished -= value;
144                         }
145                 }
146                 
147                 public event BuildStartedEventHandler BuildStarted {
148                         add {
149                                 lock (this)
150                                         buildStarted += value;
151                         }
152                         remove {
153                                 lock (this)
154                                         buildStarted -= value;
155                         }
156                 }
157                 
158                 public event CustomBuildEventHandler CustomEventRaised {
159                         add {
160                                 lock (this)
161                                         customEventRaised += value;
162                         }
163                         remove {
164                                 lock (this)
165                                         customEventRaised -= value;
166                         }
167                 }
168                 
169                 public event BuildErrorEventHandler ErrorRaised {
170                         add {
171                                 lock (this)
172                                         errorRaised += value;
173                         }
174                         remove {
175                                 lock (this)
176                                         errorRaised -= value;
177                         }
178                 }
179                 
180                 public event BuildMessageEventHandler MessageRaised {
181                         add {
182                                 lock (this)
183                                         messageRaised += value;
184                         }
185                         remove {
186                                 lock (this)
187                                         messageRaised -= value;
188                         }
189                 }
190                 
191                 public event ProjectFinishedEventHandler ProjectFinished {
192                         add {
193                                 lock (this)
194                                         projectFinished += value;
195                         }
196                         remove {
197                                 lock (this)
198                                         projectFinished -= value;
199                         }
200                 }
201                 
202                 public event ProjectStartedEventHandler ProjectStarted {
203                         add {
204                                 lock (this)
205                                         projectStarted += value;
206                         }
207                         remove {
208                                 lock (this)
209                                         projectStarted -= value;
210                         }
211                 }
212                 
213                 public event BuildStatusEventHandler StatusEventRaised {
214                         add {
215                                 lock (this)
216                                         statusEventRaised += value;
217                         }
218                         remove {
219                                 lock (this)
220                                         statusEventRaised -= value;
221                         }
222                 }
223                 
224                 public event TargetFinishedEventHandler TargetFinished {
225                         add {
226                                 lock (this)
227                                         targetFinished += value;
228                         }
229                         remove {
230                                 lock (this)
231                                         targetFinished -= value;
232                         }
233                 }
234                 
235                 public event TargetStartedEventHandler TargetStarted {
236                         add {
237                                 lock (this)
238                                         targetStarted += value;
239                         }
240                         remove {
241                                 lock (this)
242                                         targetStarted -= value;
243                         }
244                 }
245                 
246                 public event TaskFinishedEventHandler TaskFinished {
247                         add {
248                                 lock (this)
249                                         taskFinished += value;
250                         }
251                         remove {
252                                 lock (this)
253                                         taskFinished -= value;
254                         }
255                 }
256                 
257                 public event TaskStartedEventHandler TaskStarted {
258                         add {
259                                 lock (this)
260                                         taskStarted += value;
261                         }
262                         remove {
263                                 lock (this)
264                                         taskStarted -= value;
265                         }
266                 }
267                 
268                 public event BuildWarningEventHandler WarningRaised {
269                         add {
270                                 lock (this)
271                                         warningRaised += value;
272                         }
273                         remove {
274                                 lock (this)
275                                         warningRaised -= value;
276                         }
277                 }
278                 
279                 public bool OnlyLogCriticalEvents {
280                         get { return onlyLogCriticalEvents; }
281                         set { onlyLogCriticalEvents = value; }
282                 }
283         }
284 }
285
286 #endif