Exemplo n.º 1
0
        public async Task ApplyPatchAsync(IProgress <DirectoryPatcherProgressReport> progressCallback, CancellationToken cancellationToken, string instructionsHash)
        {
            var             actions        = new List <IFilePatchAction>();
            var             progress       = new DirectoryPatcherProgressReport();
            Action <Action> reportProgress = (phaseAction) => {
                phaseAction();
                progressCallback.Report(ObjectEx.DeepClone(progress));
            };
            var loadPhase = new LoadPhase(cancellationToken, phaseProgress => reportProgress(() => progress.Load = phaseProgress));

            await AnalyzeAsync(cancellationToken, action =>
            {
                loadPhase.StartLoading(action);
                actions.Add(action);
            }, phaseProgress => reportProgress(() => progress.Analyze = phaseProgress), instructionsHash);

            await loadPhase.AwaitAllTasksAndFinish();

            await ApplyAsync(cancellationToken, actions, phaseProgress => reportProgress(() => progress.Apply = phaseProgress));
        }
Exemplo n.º 2
0
        public async Task ApplyPatchAsync(IProgress <DirectoryPatcherProgressReport> progressCallback, CancellationToken cancellationToken, string instructions_hash)
        {
            var             actions        = new List <IFilePatchAction>();
            var             progress       = new DirectoryPatcherProgressReport();
            Action <Action> reportProgress = (phaseAction) => {
                phaseAction();
                progressCallback.Report(ObjectEx.DeepClone(progress));
            };
            var loadPhase = new LoadPhase(cancellationToken, phaseProgress => reportProgress(() => progress.Load = phaseProgress));

            // Analyze files to determine which files to download and how to download them
            await Analyze(cancellationToken, action =>
            {
                loadPhase.StartLoading(action);
                actions.Add(action);
            }, phaseProgress => reportProgress(() => progress.Analyze = phaseProgress), instructions_hash);

            // Wait for downloads to finish
            await loadPhase.AwaitAllTasksAndFinish();

            // Apply the new files
            await Apply(actions, phaseProgress => reportProgress(() => progress.Apply = phaseProgress));
        }