TestConfigurationSetProgressOutput.cs (2576B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="TestConfigurationSetProgressOutput.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.WinGet.Configuration.Engine.Helpers 8 { 9 using Microsoft.Management.Configuration; 10 using Microsoft.WinGet.Common.Command; 11 using Windows.Foundation; 12 13 /// <summary> 14 /// Helper to handle progress callbacks for TestSetAsync. 15 /// </summary> 16 internal class TestConfigurationSetProgressOutput : ConfigurationSetProgressOutputBase<TestConfigurationSetResult, TestConfigurationUnitResult> 17 { 18 private bool isFirstProgress = true; 19 20 /// <summary> 21 /// Initializes a new instance of the <see cref="TestConfigurationSetProgressOutput"/> class. 22 /// </summary> 23 /// <param name="cmd">Command that outputs the messages.</param> 24 /// <param name="activityId">The activity id of the progress bar.</param> 25 /// <param name="activity">The activity.</param> 26 /// <param name="inProgressMessage">The message in the progress bar.</param> 27 /// <param name="completeMessage">The activity complete message.</param> 28 /// <param name="totalUnitsExpected">Total of units expected.</param> 29 public TestConfigurationSetProgressOutput(PowerShellCmdlet cmd, int activityId, string activity, string inProgressMessage, string completeMessage, int totalUnitsExpected) 30 : base(cmd, activityId, activity, inProgressMessage, completeMessage, totalUnitsExpected) 31 { 32 } 33 34 /// <inheritdoc/> 35 public override void Progress(IAsyncOperationWithProgress<TestConfigurationSetResult, TestConfigurationUnitResult> operation, TestConfigurationUnitResult data) 36 { 37 if (this.isFirstProgress) 38 { 39 this.HandleProgress(operation.GetResults()); 40 } 41 42 this.CompleteUnit(data.Unit); 43 } 44 45 /// <inheritdoc/> 46 public override void HandleProgress(TestConfigurationSetResult result) 47 { 48 if (!this.isFirstProgress) 49 { 50 this.isFirstProgress = false; 51 foreach (var unitResult in result.UnitResults) 52 { 53 this.CompleteUnit(unitResult.Unit); 54 } 55 } 56 } 57 } 58 }