ConvertToWinGetConfigurationYamlCmdlet.cs (1493B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="ConvertToWinGetConfigurationYamlCmdlet.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 /// ConvertTo-WinGetConfigurationYaml 15 /// Serializes a PSConfigurationSet to a YAML string. 16 /// </summary> 17 [Cmdlet(VerbsData.ConvertTo, "WinGetConfigurationYaml")] 18 [Alias("ctwgcy")] 19 public sealed class ConvertToWinGetConfigurationYamlCmdlet : PSCmdlet 20 { 21 /// <summary> 22 /// Gets or sets the configuration set. 23 /// </summary> 24 [Parameter( 25 Position = 0, 26 Mandatory = true, 27 ValueFromPipeline = true, 28 ValueFromPipelineByPropertyName = true)] 29 public PSConfigurationSet Set { get; set; } 30 31 /// <summary> 32 /// Converts the given set to a string. 33 /// </summary> 34 protected override void ProcessRecord() 35 { 36 var configCommand = new ConfigurationCommand(this); 37 configCommand.Serialize(this.Set); 38 } 39 } 40 }