winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

RepairOperationWithProgress.cs (1833B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="RepairOperationWithProgress.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.WinGet.Client.Engine.Helpers
      8 {
      9     using System;
     10     using System.Management.Automation;
     11     using Microsoft.Management.Deployment;
     12     using Microsoft.WinGet.Common.Command;
     13     using Microsoft.WinGet.Resources;
     14     using Windows.Foundation;
     15 
     16     /// <summary>
     17     /// Handler for Repair Operation with Progress.
     18     /// </summary>
     19     internal class RepairOperationWithProgress : OperationWithProgressBase<RepairResult, RepairProgress>
     20     {
     21         /// <summary>
     22         /// Initializes a new instance of the <see cref="RepairOperationWithProgress"/> class.
     23         /// </summary>
     24         /// <param name="pwshCmdlet"> instance.</param>
     25         /// <param name="activity">Activity.</param>
     26         public RepairOperationWithProgress(PowerShellCmdlet pwshCmdlet, string activity)
     27             : base(pwshCmdlet, activity)
     28         {
     29         }
     30 
     31         /// <inheritdoc/>
     32         public override void Progress(IAsyncOperationWithProgress<RepairResult, RepairProgress> operation, RepairProgress progress)
     33         {
     34             ProgressRecord record = new (this.ActivityId, this.Activity, progress.State.ToString())
     35             {
     36                 RecordType = ProgressRecordType.Processing,
     37             };
     38 
     39             record.StatusDescription = Resources.Repairing;
     40             record.PercentComplete = (int)(progress.RepairCompletionProgress * 100);
     41             this.PwshCmdlet.Write(StreamType.Progress, record);
     42         }
     43     }
     44 }