2024-08-05 18:02:01 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Management.Automation;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using YamlDotNet.Serialization;
|
|
|
|
|
|
using YamlDotNet.Serialization.NamingConventions;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.SDK.PowerShell.Cmdlets
|
|
|
|
|
|
{
|
|
|
|
|
|
[Cmdlet(VerbsData.ConvertFrom, "SerializedBase64")]
|
|
|
|
|
|
[OutputType(typeof(object))]
|
2026-01-24 16:37:07 -06:00
|
|
|
|
public class ConvertFromSerializedBase64Cmdlet : Cmdlet
|
2024-08-05 18:02:01 -05:00
|
|
|
|
{
|
2026-05-08 02:02:33 -05:00
|
|
|
|
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "A Base64-encoded string containing YAML-serialized data to deserialize.")]
|
2024-08-05 18:02:01 -05:00
|
|
|
|
public string Input { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected override void ProcessRecord()
|
|
|
|
|
|
{
|
|
|
|
|
|
var yaml = Encoding.UTF8.GetString(Convert.FromBase64String(Input));
|
|
|
|
|
|
|
|
|
|
|
|
var deserializer = new DeserializerBuilder()
|
|
|
|
|
|
.IgnoreUnmatchedProperties()
|
|
|
|
|
|
.WithNamingConvention(new PascalCaseNamingConvention())
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
WriteObject(deserializer.Deserialize<object>(yaml));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|