2 // EventSource.cs: Implements IEventSource.
5 // Marek Sieradzki (marek.sieradzki@gmail.com)
7 // (C) 2005 Marek Sieradzki
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
30 using Microsoft.Build.Framework;
32 namespace Microsoft.Build.BuildEngine {
33 internal class EventSource : IEventSource {
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;
53 this.onlyLogCriticalEvents = false;
56 public void FireCustomEventRaised (object sender, CustomBuildEventArgs cbea)
58 if (customEventRaised != null)
59 customEventRaised (sender, cbea);
61 public void FireErrorRaised (object sender, BuildErrorEventArgs beea)
63 if (errorRaised != null)
64 errorRaised (sender, beea);
66 public void FireMessageRaised (object sender, BuildMessageEventArgs bmea)
68 if (messageRaised != null)
69 messageRaised (sender, bmea);
71 public void FireWarningRaised (object sender, BuildWarningEventArgs bwea)
73 if (warningRaised != null)
74 warningRaised (sender, bwea);
77 public void FireTargetStarted (object sender, TargetStartedEventArgs tsea)
79 if (targetStarted != null)
80 targetStarted (sender, tsea);
83 public void FireTargetFinished (object sender, TargetFinishedEventArgs tfea)
85 if (targetFinished != null)
86 targetFinished (sender, tfea);
89 public void FireBuildStarted (object sender, BuildStartedEventArgs bsea)
91 if (buildStarted != null)
92 buildStarted (sender, bsea);
95 public void FireBuildFinished (object sender, BuildFinishedEventArgs bfea)
97 if (buildFinished != null)
98 buildFinished (sender, bfea);
101 public void FireProjectStarted (object sender, ProjectStartedEventArgs psea)
103 if (projectStarted != null)
104 projectStarted (sender, psea);
107 public void FireProjectFinished (object sender, ProjectFinishedEventArgs pfea)
109 if (projectFinished != null)
110 projectFinished (sender, pfea);
113 public void FireTaskStarted (object sender, TaskStartedEventArgs tsea)
115 if (taskStarted != null)
116 taskStarted (sender, tsea);
119 public void FireTaskFinished (object sender, TaskFinishedEventArgs tfea)
121 if (taskFinished != null)
122 taskFinished (sender, tfea);
125 public event AnyEventHandler AnyEventRaised {
128 anyEventRaised += value;
132 anyEventRaised -= value;
136 public event BuildFinishedEventHandler BuildFinished {
139 buildFinished += value;
143 buildFinished -= value;
147 public event BuildStartedEventHandler BuildStarted {
150 buildStarted += value;
154 buildStarted -= value;
158 public event CustomBuildEventHandler CustomEventRaised {
161 customEventRaised += value;
165 customEventRaised -= value;
169 public event BuildErrorEventHandler ErrorRaised {
172 errorRaised += value;
176 errorRaised -= value;
180 public event BuildMessageEventHandler MessageRaised {
183 messageRaised += value;
187 messageRaised -= value;
191 public event ProjectFinishedEventHandler ProjectFinished {
194 projectFinished += value;
198 projectFinished -= value;
202 public event ProjectStartedEventHandler ProjectStarted {
205 projectStarted += value;
209 projectStarted -= value;
213 public event BuildStatusEventHandler StatusEventRaised {
216 statusEventRaised += value;
220 statusEventRaised -= value;
224 public event TargetFinishedEventHandler TargetFinished {
227 targetFinished += value;
231 targetFinished -= value;
235 public event TargetStartedEventHandler TargetStarted {
238 targetStarted += value;
242 targetStarted -= value;
246 public event TaskFinishedEventHandler TaskFinished {
249 taskFinished += value;
253 taskFinished -= value;
257 public event TaskStartedEventHandler TaskStarted {
260 taskStarted += value;
264 taskStarted -= value;
268 public event BuildWarningEventHandler WarningRaised {
271 warningRaised += value;
275 warningRaised -= value;
279 public bool OnlyLogCriticalEvents {
280 get { return onlyLogCriticalEvents; }
281 set { onlyLogCriticalEvents = value; }