コード例 #1
0
        public override async Task <IPackage> StartPackageDownload()
        {
            Log.Debug("Starting download of package", this);
            OnOperationStatusChanged(new ProcessStatusEventArgs("Downloading files...", ComponentType));
            string packagePath = _destination;
            await _webclient.DownloadFileTaskAsync(DownloadUrl, packagePath, new Progress <Tuple <long, int, long> >(t =>
            {
                ProgressChangedEventArgs a = new ProgressChangedEventArgs(t.Item2, this);
                OnDownloadProgressChanged(a);
            }));

            var pkg = new VKPackage(Name, Version, packagePath, ComponentType);

            OnOperationStatusChanged(new ProcessStatusEventArgs("Download finished", ComponentType));
            return(pkg);
        }
コード例 #2
0
        public virtual async Task <IPackage> StartPackageDownload()
        {
            Log.Debug("Starting download of package", this);
            OnOperationStatusChanged(new ProcessStatusEventArgs("Downloading files...", ComponentType));
            packagePath = Path.GetTempPath() + DownloadUrl.Segments[DownloadUrl.Segments.Length - 1];
            await _webclient.DownloadFileTaskAsync(DownloadUrl, packagePath, new Progress <Tuple <long, int, long> >(t =>
            {
                ProgressChangedEventArgs a = new ProgressChangedEventArgs(t.Item2, this);
                OnDownloadProgressChanged(a);
            }));

            var pkg = new VKPackage(Name, Version, packagePath, ComponentType);

            OnOperationStatusChanged(new ProcessStatusEventArgs("Download finished", ComponentType));
            return(pkg);
        }
コード例 #3
0
        public virtual async Task <IPackage> StartPackageDownloadWithDependencies(bool forceDependencyDownload)
        {
            OnOperationStatusChanged(new ProcessStatusEventArgs($"Downloading package {Name}...", ComponentType));
            packagePath = Path.GetTempPath() + DownloadUrl.Segments[DownloadUrl.Segments.Length - 1];
            await _webclient.DownloadFileTaskAsync(DownloadUrl, packagePath, new Progress <Tuple <long, int, long> >(t =>
            {
                ProgressChangedEventArgs a = new ProgressChangedEventArgs(t.Item2, this);
                OnDownloadProgressChanged(a);
            }));

            var p = new VKPackage(Name, Version, packagePath, ComponentType);

            //Download all depencencies
            if (Dependencies != null)
            {
                List <IPackage> dep = new List <IPackage>();
                foreach (var v in Dependencies)
                {
                    if (!ProgramDetector.IsVoukoderComponentInstalled(v) || forceDependencyDownload)
                    {
                        OnOperationStatusChanged(new ProcessStatusEventArgs($"Downloading package dependency  {v.ComponentType} {v.Name}...", ComponentType));
                        packagePath = Path.GetTempPath() + v.DownloadUrl.Segments[v.DownloadUrl.Segments.Length - 1];
                        await _webclient.DownloadFileTaskAsync(v.DownloadUrl, packagePath, new Progress <Tuple <long, int, long> >(t =>
                        {
                            ProgressChangedEventArgs a = new ProgressChangedEventArgs(t.Item2, this);
                            OnDownloadProgressChanged(a);
                        }));

                        dep.Add(new VKPackage(v.Name, v.Version, packagePath, v.ComponentType));
                    }
                }
                p.Dependencies = dep;
            }
            OnOperationStatusChanged(new ProcessStatusEventArgs("Download finished", ComponentType));
            return(p);
        }