public static IDownloaderBuilder UseDefaultConfigure(this IDownloaderBuilder @this) => @this .Configure(request => { request.Headers.SetHeaders(new WebHeaderCollection { ["User-Agent"] = "Accelerider.Windows.DownloadEngine" }); request.Method = "GET"; request.Timeout = 1000 * 30; request.ReadWriteTimeout = 1000 * 30; return(request); }) .Configure(localPath => localPath.GetUniqueLocalPath()) .Configure(DefaultBlockIntervalGenerator) .Configure((settings, context) => { settings.MaxConcurrent = 16; settings.BuildPolicy = Policy .Handle <WebException>(e => e.Status != WebExceptionStatus.RequestCanceled) .RetryAsync(BuildExceptionRetryCount, (e, retryCount, policyContext) => { var remotePath = ((WebException)e).Response?.ResponseUri.OriginalString; if (!string.IsNullOrEmpty(remotePath)) { context.RemotePathProvider.Rate(remotePath, -1); } }); settings.DownloadPolicy .Catch <OperationCanceledException>((e, retryCount, blockContext) => HandleCommand.Break) .Catch <WebException>((e, retryCount, blockContext) => retryCount < WebExceptionRetryCount ? HandleCommand.Retry : HandleCommand.Throw) .Catch <RemotePathExhaustedException>((e, retryCount, blockContext) => HandleCommand.Throw) .Catch <IOException>((e, retryCount, blockContext) => e.IsNotEnoughDiskSpace() ? HandleCommand.Throw : HandleCommand.Retry); });
public static IDownloaderBuilder UseDefaultConfigure(this IDownloaderBuilder @this) => @this .Configure(request => { request.Headers.SetHeaders(new WebHeaderCollection { ["User-Agent"] = "Accelerider.Windows.DownloadEngine" }); request.Method = "GET"; request.Timeout = 1000 * 30; request.ReadWriteTimeout = 1000 * 30; return(request); }) .Configure(localPath =>
public static IDownloaderBuilder UseConfigure(this IDownloaderBuilder @this, string configureTag) { switch (configureTag) { case DefaultConfigureTag: return(@this.UseDefaultConfigure()); case BaiduCloudConfigureTag: return(@this.UseBaiduCloudConfigure()); case OneDriveConfigureTag: return(@this.UseOneDriveConfigure()); case OneOneFiveCloudConfigureTag: return(@this.UseOneOneFiveCloudConfigure()); case SixCloudConfigureTag: return(@this.UseSixCloudConfigure()); default: return(@this); } }
public static IDownloaderBuilder UseOneDriveConfigure(this IDownloaderBuilder @this) => @this .UseDefaultConfigure();
public static IDownloaderBuilder UseBaiduCloudConfigure(this IDownloaderBuilder @this) => @this .UseDefaultConfigure();
public static IDownloader Build(this IDownloaderBuilder @this, string jsonText) { var data = jsonText.ToObject <DownloadSerializedData>(); return(@this.Build(data.Context, data.BlockContexts)); }
public static IDownloaderBuilder From(this IDownloaderBuilder @this, Func <Task <string> > remotePathGetter) { return(@this.From(new AsyncRemotePathProvider(remotePathGetter))); }
public static IDownloaderBuilder From(this IDownloaderBuilder @this, IEnumerable <string> paths) { return(@this.From(new ConstantRemotePathProvider(new HashSet <string>(paths)))); }
public static IDownloaderBuilder From(this IDownloaderBuilder @this, string path) => @this.From(new[] { path });