blob: ea058782212dfcb797a3c3310cd5b3f97a380da0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
using Gorilla.Commons.Infrastructure.Logging;
using Gorilla.Commons.Utility;
using Gorilla.Commons.Utility.Core;
using MoMoney.DTO;
using MoMoney.Presentation.Core;
using MoMoney.Presentation.Presenters.Commands;
using MoMoney.Presentation.Views.updates;
using MoMoney.Service.Contracts.Infrastructure.Updating;
using MoMoney.Service.Infrastructure.Updating;
using MoMoney.Tasks.infrastructure.updating;
namespace MoMoney.Presentation.Presenters.updates
{
public interface ICheckForUpdatesPresenter : IPresenter, ICallback<Percent>
{
void begin_update();
void cancel_update();
void restart();
void do_not_update();
}
public class CheckForUpdatesPresenter : ICheckForUpdatesPresenter
{
readonly ICheckForUpdatesView view;
readonly ICommandPump pump;
public CheckForUpdatesPresenter(ICheckForUpdatesView view, ICommandPump pump)
{
this.pump = pump;
this.view = view;
}
public void run()
{
pump.run<ApplicationVersion, IWhatIsTheAvailableVersion>(view);
view.attach_to(this);
view.display();
}
public void begin_update()
{
pump.run<IDownloadTheLatestVersion, ICallback<Percent>>(this);
}
public void cancel_update()
{
pump.run<ICancelUpdate>();
view.close();
}
public void restart()
{
pump.run<IRestartCommand>();
}
public void do_not_update()
{
view.close();
}
public void run(Percent completed)
{
if (completed.Equals(new Percent(100)))
{
this.log().debug("completed download");
view.update_complete();
restart();
}
else
{
this.log().debug("completed {0}", completed);
view.downloaded(completed);
}
}
}
}
|