예제 #1
0
        protected virtual async Task CopyFileEntries([NotNull] CopyCallback callback, IProgress <AsyncProgressEntry> progress, CancellationToken cancellation)
        {
            var list = (await GetFileEntriesAsync(cancellation))?.ToList();

            if (list == null)
            {
                return;
            }

            for (var i = 0; i < list.Count; i++)
            {
                var fileInfo    = list[i];
                var destination = callback(fileInfo);
                if (destination != null)
                {
                    FileUtils.EnsureFileDirectoryExists(destination);
                    progress?.Report(Path.GetFileName(destination), i, list.Count);
                    await fileInfo.CopyToAsync(destination);

                    if (cancellation.IsCancellationRequested)
                    {
                        return;
                    }
                }
            }
        }
예제 #2
0
 public InstallationDetails([NotNull] CopyCallback copyCallback, [CanBeNull] string[] toRemoval,
                            [CanBeNull] Func <CancellationToken, Task> beforeTask, [CanBeNull] Func <CancellationToken, Task> afterTask)
 {
     CopyCallback = copyCallback;
     ToRemoval    = toRemoval ?? new string[0];
     BeforeTask   = beforeTask;
     AfterTask    = afterTask;
 }
예제 #3
0
 public async Task InstallAsync([NotNull] CopyCallback callback,
                                IProgress <AsyncProgressEntry> progress, CancellationToken cancellation)
 {
     await CopyFileEntries(callback, progress, cancellation);
 }