SDownload.Framework.Streams.BaseStream.Download C# (CSharp) Method

Download() public method

Downloads the Sound representation and any extra files that accompany it If true, extra files will not be downloaded. (Useful for retrying the main download) A boolean value representing if the download was successful or not
public Download ( bool ignoreExtras = false ) : Task
ignoreExtras bool
return Task
        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;
        }