OpenConfiguration.cs (2941B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="OpenConfiguration.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.WinGet.Configuration.Cmdlets.Common 8 { 9 using System.Management.Automation; 10 using Microsoft.PowerShell; 11 using Microsoft.WinGet.Configuration.Helpers; 12 13 /// <summary> 14 /// The parameters used to open a configuration. 15 /// </summary> 16 public abstract class OpenConfiguration : PSCmdlet 17 { 18 /// <summary> 19 /// Gets or sets the configuration file. 20 /// </summary> 21 [Parameter( 22 Position = 0, 23 Mandatory = true, 24 ValueFromPipelineByPropertyName = true, 25 ParameterSetName = Constants.ParameterSet.OpenConfigurationSetFromFile)] 26 public string File { get; set; } 27 28 /// <summary> 29 /// Gets or sets the configuration history item identifier. 30 /// </summary> 31 [Parameter( 32 Position = 0, 33 Mandatory = true, 34 ValueFromPipelineByPropertyName = true, 35 ParameterSetName = Constants.ParameterSet.OpenConfigurationSetFromHistory)] 36 public string InstanceIdentifier { get; set; } 37 38 /// <summary> 39 /// Gets or sets a value indicating whether all configuration history items should be returned. 40 /// </summary> 41 [Parameter( 42 Mandatory = true, 43 ParameterSetName = Constants.ParameterSet.OpenAllConfigurationSetsFromHistory)] 44 public SwitchParameter All { get; set; } 45 46 /// <summary> 47 /// Gets or sets custom location to install modules. 48 /// </summary> 49 [Parameter( 50 Position = 1, 51 ValueFromPipelineByPropertyName = true)] 52 public string ModulePath { get; set; } 53 54 /// <summary> 55 /// Gets or sets custom DSCv3 processor path. 56 /// </summary> 57 [Parameter(ValueFromPipelineByPropertyName = true)] 58 public string ProcessorPath { get; set; } 59 60 /// <summary> 61 /// Gets the execution policy to use. 62 /// </summary> 63 protected ExecutionPolicy ExecutionPolicy { get; private set; } = ExecutionPolicy.Undefined; 64 65 /// <summary> 66 /// Gets a value indicating whether to use telemetry or not. 67 /// </summary> 68 protected bool CanUseTelemetry { get; private set; } 69 70 /// <summary> 71 /// Pre-processing operations. 72 /// </summary> 73 protected override void BeginProcessing() 74 { 75 this.ExecutionPolicy = Utilities.GetExecutionPolicy(); 76 this.CanUseTelemetry = Utilities.CanUseTelemetry(); 77 } 78 } 79 }