This does a very basic job of bundling a PowerShell runtime into the SDK. Previously, scripts had been run by spawning a separate PowerShell process and feeding the script into it. This was nothing better than a hack and meant that PowerShell had to be separately installed on the machine it's executing on. This should open up the opportunity for scripts to run on other platforms. There's still some things that need to be figured out. Some sort of console output as well as a debugging mode would be highly beneficial for those that wish to actively develop scripts for their games.
30 lines
962 B
C#
30 lines
962 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Management.Automation;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using YamlDotNet.Serialization.NamingConventions;
|
|
using YamlDotNet.Serialization;
|
|
|
|
namespace LANCommander.SDK.PowerShell.Cmdlets
|
|
{
|
|
[Cmdlet(VerbsData.ConvertTo, "SerializedBase64")]
|
|
[OutputType(typeof(object))]
|
|
public class ConvertToSerializedBase64Cmdlet : Cmdlet
|
|
{
|
|
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
|
|
public object Input { get; set; }
|
|
|
|
protected override void ProcessRecord()
|
|
{
|
|
var serializer = new SerializerBuilder()
|
|
.WithNamingConvention(new PascalCaseNamingConvention())
|
|
.Build();
|
|
|
|
var output = Convert.ToBase64String(Encoding.UTF8.GetBytes(serializer.Serialize(Input)));
|
|
|
|
WriteObject(output);
|
|
}
|
|
}
|
|
}
|