/// <summary> /// Downloads the Sound representation and any extra files that accompany it /// <param name="ignoreExtras">If true, extra files will not be downloaded. (Useful for retrying the main download)</param> /// <returns>A boolean value representing if the download was successful or not</returns> /// </summary> public virtual async Task <bool> Download(bool ignoreExtras = false) { View.Report("Downloading..."); try { // Download the main resource if (MainResource == null) { CrashHandler.Throw("No resource has been registered for download!"); return(false); } var mainDownloader = new WebClient(); mainDownloader.DownloadProgressChanged += (sender, e) => View.UpdateProgress(e.ProgressPercentage); var resourceDownload = mainDownloader.DownloadFileTaskAsync(MainResource.Uri, MainResource.AbsolutePath); IEnumerable <Task> extraTasks = null; // Download additional files if (!ignoreExtras) { extraTasks = (from extra in Extras select DownloadExtra(extra)).ToList(); } await resourceDownload; var ret = Validate(); if (extraTasks != null) { foreach (var extra in extraTasks) { await extra; } } return(await ret); } catch (Exception e) { LastException = e; } return(false); }
/// <summary> /// Creates a base stream that downloads from a remote url /// </summary> /// <param name="url">The url to process</param> /// <param name="view">The view to report information back to</param> protected BaseStream(String url, InfoReportProxy view) { View = view; View.Report("Processing"); }