winget-cli

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

UninstallOperationWithProgress.cs (1864B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="UninstallOperationWithProgress.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.Management.Automation;
     10     using Microsoft.Management.Deployment;
     11     using Microsoft.WinGet.Common.Command;
     12     using Microsoft.WinGet.Resources;
     13     using Windows.Foundation;
     14 
     15     /// <summary>
     16     /// Handler progress for uninstall.
     17     /// </summary>
     18     internal class UninstallOperationWithProgress : OperationWithProgressBase<UninstallResult, UninstallProgress>
     19     {
     20         /// <summary>
     21         /// Initializes a new instance of the <see cref="UninstallOperationWithProgress"/> class.
     22         /// </summary>
     23         /// <param name="pwshCmdlet">A <see cref="PowerShellCmdlet" /> instance.</param>
     24         /// <param name="activity">Activity.</param>
     25         public UninstallOperationWithProgress(PowerShellCmdlet pwshCmdlet, string activity)
     26             : base(pwshCmdlet, activity)
     27         {
     28         }
     29 
     30         /// <inheritdoc/>
     31         public override void Progress(IAsyncOperationWithProgress<UninstallResult, UninstallProgress> operation, UninstallProgress progress)
     32         {
     33             ProgressRecord record = new (this.ActivityId, this.Activity, progress.State.ToString())
     34             {
     35                 RecordType = ProgressRecordType.Processing,
     36             };
     37             record.StatusDescription = Resources.Uninstalling;
     38             record.PercentComplete = (int)(progress.UninstallationProgress * 100);
     39             this.PwshCmdlet.Write(StreamType.Progress, record);
     40         }
     41     }
     42 }