コード例 #1
0
ファイル: SelfUpdate.cs プロジェクト: hummerd/AppManager
 public SelfUpdate()
 {
     FileDownloaderFactory = new FileDownloaderFactory();
     VNPFactory            = new VersionNumberFactory();
     UIAskDownload         = new UIAsk();
     UIAskInstall          = new UIAsk();
     UIDownloadProgress    = new UIDownloadProgress();
 }
コード例 #2
0
ファイル: SelfUpdate.cs プロジェクト: hummerd/AppManager
        protected string DownloadVersion(
            VersionManifest downloadManifest,
            string appName,
            Version latestVersion,
            string updateUri
            )
        {
            var tempApplicationPath = String.Empty;

            if (UIDownloadProgress != null)
            {
                DispatcherHelper.Invoke(new SimpleMethod(UIDownloadProgress.Show));
                DispatcherHelper.Invoke(new SetDownloadProgressInfo(UIDownloadProgress.SetDownloadInfo),
                                        downloadManifest);
            }

            try
            {
                var fileDownloader = FileDownloaderFactory.GetFileDownloader(new Uri(updateUri).Scheme);
                fileDownloader.DownloadFileStarted += (s, e) =>
                                                      DispatcherHelper.Invoke(new UpdateDownloadProgress(
                                                                                  UIDownloadProgress.SetDownloadProgress), e.FilePath, e.ToltalSize, e.DownloadedSize);

                var downloadItems = new List <LocationHash>(downloadManifest.VersionItems.Count);
                foreach (var item in downloadManifest.VersionItems)
                {
                    if (item.InstallAction != InstallAction.Delete)
                    {
                        downloadItems.Add(item.GetLocationHash());
                    }
                }

                tempApplicationPath = CreateTempDir(appName, latestVersion);
                fileDownloader.DownloadFileSet(
                    downloadItems,
                    tempApplicationPath);

                var tempInstallerPath = CreateInstallerDir(tempApplicationPath, appName, latestVersion);
                fileDownloader.DownloadFileSet(
                    downloadManifest.BootStrapper,
                    tempInstallerPath);
            }
            finally
            {
                if (UIDownloadProgress != null)
                {
                    DispatcherHelper.Invoke(
                        new SimpleMethod(UIDownloadProgress.Close));
                }
            }

            return(tempApplicationPath);
        }