summaryrefslogtreecommitdiff
path: root/product/Service/Infrastructure/Updating/DownloadTheLatestVersion.cs
blob: 962592a2c4d911c181f3d2c43320f4cf4d01c3d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using Gorilla.Commons.Utility;
using Gorilla.Commons.Utility.Core;

namespace MoMoney.Service.Infrastructure.Updating
{
    public class DownloadTheLatestVersion : IDownloadTheLatestVersion
    {
        readonly IDeployment deployment;

        public DownloadTheLatestVersion(IDeployment deployment)
        {
            this.deployment = deployment;
        }

        public void run(ICallback<Percent> callback)
        {
            deployment.UpdateProgressChanged += (o, e) => callback.run(new Percent(e.BytesCompleted, e.BytesTotal));
            deployment.UpdateCompleted += (sender, args) => callback.run(100);
            deployment.UpdateAsync();
        }
    }
}