SourceCommand.cs (1544B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="SourceCommand.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 8 { 9 using System.Management.Automation; 10 using Microsoft.WinGet.Client.Engine.Commands.Common; 11 using Microsoft.WinGet.Client.Engine.PSObjects; 12 using Microsoft.WinGet.Common.Command; 13 14 /// <summary> 15 /// Wrapper for source cmdlets. 16 /// </summary> 17 public sealed class SourceCommand : ManagementDeploymentCommand 18 { 19 /// <summary> 20 /// Initializes a new instance of the <see cref="SourceCommand"/> class. 21 /// Wrapper for Source commands. 22 /// </summary> 23 /// <param name="psCmdlet">Caller cmdlet.</param> 24 public SourceCommand(PSCmdlet psCmdlet) 25 : base(psCmdlet) 26 { 27 } 28 29 /// <summary> 30 /// Get-WinGetSource. 31 /// </summary> 32 /// <param name="name">Optional name.</param> 33 public void Get(string name) 34 { 35 var results = this.Execute( 36 () => this.GetPackageCatalogReferences(name)); 37 for (var i = 0; i < results.Count; i++) 38 { 39 this.Write(StreamType.Object, new PSSourceResult(results[i])); 40 } 41 } 42 } 43 }