root / trunk / Pithos.Core / Agents / Notifier.cs @ 8f44fd3a
History | View | Annotate | Download (1.2 kB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
|
6 |
namespace Pithos.Core |
7 |
{ |
8 |
public class Notifier:IDisposable |
9 |
{ |
10 |
private readonly IStatusNotification _statusNotification; |
11 |
|
12 |
private readonly Notification _endNotification; |
13 |
|
14 |
public Notifier(IStatusNotification statusNotification,string startMessage,string endMessage) |
15 |
:this(statusNotification,new Notification{Message=startMessage},new Notification{Message=endMessage} ) |
16 |
{ |
17 |
|
18 |
} |
19 |
|
20 |
public Notifier(IStatusNotification statusNotification,Notification startNotification,Notification endNotification) |
21 |
{ |
22 |
_statusNotification = statusNotification; |
23 |
_endNotification = endNotification; |
24 |
_statusNotification.Notify(startNotification); |
25 |
} |
26 |
|
27 |
|
28 |
public void Dispose() |
29 |
{ |
30 |
Dispose(true); |
31 |
GC.SuppressFinalize(this); |
32 |
} |
33 |
|
34 |
~Notifier() |
35 |
{ |
36 |
Dispose(false); |
37 |
} |
38 |
|
39 |
protected virtual void Dispose(bool disposing) |
40 |
{ |
41 |
if (disposing) |
42 |
{ |
43 |
_statusNotification.Notify(_endNotification); |
44 |
} |
45 |
} |
46 |
} |
47 |
} |