winget-cli

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

ConfirmWinGetConfigurationCmdlet.cs (1820B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="ConfirmWinGetConfigurationCmdlet.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.WinGet.Configuration.Cmdlets
      8 {
      9     using System.Management.Automation;
     10     using Microsoft.WinGet.Configuration.Engine.Commands;
     11     using Microsoft.WinGet.Configuration.Engine.PSObjects;
     12 
     13     /// <summary>
     14     /// Confirm-WinGetConfiguration
     15     /// Validates winget configuration.
     16     /// </summary>
     17     [Cmdlet(VerbsLifecycle.Confirm, "WinGetConfiguration")]
     18     [Alias("cnwgc")]
     19     public class ConfirmWinGetConfigurationCmdlet : PSCmdlet
     20     {
     21         private ConfigurationCommand runningCommand = null;
     22 
     23         /// <summary>
     24         /// Gets or sets the configuration set.
     25         /// </summary>
     26         [Parameter(
     27             Position = 0,
     28             Mandatory = true,
     29             ValueFromPipeline = true,
     30             ValueFromPipelineByPropertyName = true)]
     31         public PSConfigurationSet Set { get; set; }
     32 
     33         /// <summary>
     34         /// Validate configuration.
     35         /// </summary>
     36         protected override void ProcessRecord()
     37         {
     38             this.runningCommand = new ConfigurationCommand(this);
     39             this.runningCommand.Validate(this.Set);
     40         }
     41 
     42         /// <summary>
     43         /// Interrupts currently running code within the command.
     44         /// </summary>
     45         protected override void StopProcessing()
     46         {
     47             if (this.runningCommand != null)
     48             {
     49                 this.runningCommand.Cancel();
     50             }
     51         }
     52     }
     53 }