FinderExtendedCommand.cs (2417B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="FinderExtendedCommand.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.WinGet.Client.Engine.Commands.Common 8 { 9 using System.Collections.Generic; 10 using System.Management.Automation; 11 using Microsoft.Management.Deployment; 12 using Microsoft.WinGet.Client.Engine.Attributes; 13 14 /// <summary> 15 /// This is the base class for the commands whose sole purpose is to filter a list of packages i.e., 16 /// the "search" and "list" commands. This class contains an extended set of parameters suited for 17 /// that purpose. 18 /// </summary> 19 public abstract class FinderExtendedCommand : FinderCommand 20 { 21 /// <summary> 22 /// Initializes a new instance of the <see cref="FinderExtendedCommand"/> class. 23 /// </summary> 24 /// <param name="psCmdlet">PSCmdlet.</param> 25 internal FinderExtendedCommand(PSCmdlet psCmdlet) 26 : base(psCmdlet) 27 { 28 } 29 30 /// <summary> 31 /// Gets or sets the filter that is matched against the tags of the package. 32 /// </summary> 33 [Filter(Field = PackageMatchField.Tag)] 34 protected string? Tag { get; set; } 35 36 /// <summary> 37 /// Gets or sets the filter that is matched against the commands of the package. 38 /// </summary> 39 [Filter(Field = PackageMatchField.Command)] 40 protected string? Command { get; set; } 41 42 /// <summary> 43 /// Gets or sets the maximum number of results returned. 44 /// </summary> 45 protected uint Count { get; set; } 46 47 /// <summary> 48 /// Searches for packages from configured sources. 49 /// </summary> 50 /// <param name="behavior">A <see cref="CompositeSearchBehavior" /> value.</param> 51 /// <param name="match">The match option.</param> 52 /// <returns>A list of <see cref="MatchResult" /> objects.</returns> 53 internal IReadOnlyList<MatchResult> FindPackages(CompositeSearchBehavior behavior, PackageFieldMatchOption match) 54 { 55 return this.FindPackages(behavior, this.Count, match); 56 } 57 } 58 }