AcManager.Tools.Helpers.Loaders.FlexibleLoader.CreateLoader C# (CSharp) Method

CreateLoader() static private method

static private CreateLoader ( string uri ) : ILoader
uri string
return ILoader
        internal static ILoader CreateLoader(string uri) {
            if (GoogleDriveLoader.Test(uri)) return new GoogleDriveLoader(uri);
            if (AcClubLoader.Test(uri)) return new AcClubLoader(uri);
            if (RaceDepartmentLoader.Test(uri)) return new RaceDepartmentLoader(uri);
            if (AssettoDbLoader.Test(uri)) return new AssettoDbLoader(uri);
            return new DirectLoader(uri);
        }

Usage Example

Example #1
0
        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, @"<p class=""download""><a href=""([^""]+)");

            if (!match.Success)
            {
                NonfatalError.Notify(ToolsStrings.Common_CannotDownloadFile, ToolsStrings.DirectLoader_AcClubChanged);
                return(false);
            }

            Url = HttpUtility.HtmlDecode(match.Groups[1].Value);
            Logging.Write("AssettoCorsa.club download link: " + Url);

            _innerLoader = FlexibleLoader.CreateLoader(Url);
            if (_innerLoader is AcClubLoader)
            {
                throw new Exception(ToolsStrings.DirectLoader_RecursionDetected);
            }
            return(await _innerLoader.PrepareAsync(client, cancellation));
        }
All Usage Examples Of AcManager.Tools.Helpers.Loaders.FlexibleLoader::CreateLoader