PackageCmdlet.cs (1750B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="PackageCmdlet.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.WinGet.Client.Commands.Common 8 { 9 using System.Management.Automation; 10 using Microsoft.WinGet.Client.Common; 11 using Microsoft.WinGet.Client.Engine.PSObjects; 12 13 /// <summary> 14 /// This is the base class for commands which operate on a specific package and version i.e., 15 /// the "install", "uninstall", and "upgrade" commands. 16 /// </summary> 17 public abstract class PackageCmdlet : FinderCmdlet 18 { 19 /// <summary> 20 /// Initializes a new instance of the <see cref="PackageCmdlet"/> class. 21 /// </summary> 22 public PackageCmdlet() 23 { 24 // The default match option for single package operations. 25 this.MatchOption = PSObjects.PSPackageFieldMatchOption.EqualsCaseInsensitive; 26 } 27 28 /// <summary> 29 /// Gets or sets the package to directly install. 30 /// </summary> 31 [Alias("InputObject")] 32 [ValidateNotNull] 33 [Parameter( 34 ParameterSetName = Constants.GivenSet, 35 Position = 0, 36 ValueFromPipeline = true, 37 ValueFromPipelineByPropertyName = true)] 38 public PSCatalogPackage PSCatalogPackage { get; set; } = null; 39 40 /// <summary> 41 /// Gets or sets the version to install. 42 /// </summary> 43 [Parameter(ValueFromPipelineByPropertyName = true)] 44 public string Version { get; set; } 45 } 46 }