AcManager.Tools.Helpers.Loaders.AssettoDbLoader.PrepareAsync C# (CSharp) Method

PrepareAsync() public method

public PrepareAsync ( WebClient client, CancellationToken cancellation ) : Task
client System.Net.WebClient
cancellation System.Threading.CancellationToken
return Task
        public override async Task<bool> PrepareAsync(WebClient client, CancellationToken cancellation) {
            var downloadPage = await client.DownloadStringTaskAsync(Url);
            if (cancellation.IsCancellationRequested) return false;

            var match = Regex.Match(downloadPage, @"href=""(/[^""]+/download)""");
            if (!match.Success) {
                NonfatalError.Notify(ToolsStrings.Common_CannotDownloadFile, ToolsStrings.DirectLoader_AssettoDbChanged);
                return false;
            }

            Url = "http://assetto-db.com" + HttpUtility.HtmlDecode(match.Groups[1].Value);
            Logging.Write("Assetto-DB.com download link: " + Url);
            return true;
        }
    }