Windows-powershell / PowerShell-master /test /powershell /engine /ExperimentalFeature /assets /ExpTest /ExpTest.cs
| // Copyright (c) Microsoft Corporation. | |
| // Licensed under the MIT License. | |
| using System; | |
| using System.Management.Automation; | |
| namespace ExperimentalFeatureTest | |
| { | |
| [] | |
| [] | |
| public class InvokeAzureFunctionCommand : PSCmdlet | |
| { | |
| [] | |
| public string Token { get; set; } | |
| [] | |
| public string Command { get; set; } | |
| protected override void EndProcessing() | |
| { | |
| WriteObject("Invoke-AzureFunction Version ONE"); | |
| } | |
| } | |
| [] | |
| [] | |
| public class InvokeAzureFunctionCommandV2 : PSCmdlet | |
| { | |
| [] | |
| public string Token { get; set; } | |
| [] | |
| public string Command { get; set; } | |
| protected override void EndProcessing() | |
| { | |
| WriteObject("Invoke-AzureFunction Version TWO"); | |
| } | |
| } | |
| [] | |
| public class GetGreetingMessageCommand : PSCmdlet | |
| { | |
| [] | |
| public string Name { get; set; } | |
| [] | |
| public SwitchParameter SwitchOne { get; set; } | |
| [] | |
| public SwitchParameter SwitchTwo { get; set; } | |
| protected override void EndProcessing() | |
| { | |
| string message = $"Hello World {Name}."; | |
| if (ExperimentalFeature.IsEnabled("ExpTest.FeatureOne")) | |
| { | |
| if (SwitchOne.IsPresent) | |
| { | |
| message += "-SwitchOne is on."; | |
| } | |
| if (SwitchTwo.IsPresent) | |
| { | |
| message += "-SwitchTwo is on."; | |
| } | |
| } | |
| WriteObject(message); | |
| } | |
| } | |
| [] | |
| public class InvokeMyCommandCommand : PSCmdlet | |
| { | |
| [] | |
| public string UserName { get; set; } | |
| [] | |
| public string ComputerName { get; set; } | |
| [] | |
| public string VMName { get; set; } | |
| // Enable web socket only if the feature is turned on. | |
| [] | |
| public string Token { get; set; } | |
| [] | |
| public string WebSocketUrl { get; set; } | |
| // Add -ConfigurationName to parameter set "WebSocketSet" only if the feature is turned on. | |
| [] | |
| [] | |
| public string ConfigurationName { get; set; } | |
| // Add -Port to parameter set "WebSocketSet" only if the feature is turned on. | |
| [] | |
| [] | |
| public int Port { get; set; } | |
| [] | |
| public int ThrottleLimit { get; set; } | |
| [] | |
| public string Command { get; set; } | |
| protected override void EndProcessing() | |
| { | |
| switch (this.ParameterSetName) | |
| { | |
| case "ComputerSet": WriteObject("Invoke-MyCommand with ComputerSet"); break; | |
| case "VMSet": WriteObject("Invoke-MyCommand with VMSet"); break; | |
| case "WebSocketSet": WriteObject("Invoke-MyCommand with WebSocketSet"); break; | |
| default: break; | |
| } | |
| } | |
| } | |
| [] | |
| public class TestMyRemotingCommand : PSCmdlet | |
| { | |
| // Replace one parameter with another one when the feature is turned on. | |
| [] | |
| public string SessionName { get; set; } | |
| [] | |
| public string ComputerName { get; set; } | |
| protected override void EndProcessing() { } | |
| } | |
| [] | |
| public class SaveMyFileCommand : PSCmdlet | |
| { | |
| [] | |
| public SwitchParameter ByUrl { get; set; } | |
| [] | |
| public SwitchParameter ByRadio { get; set; } | |
| [] | |
| public string FileName { get; set; } | |
| [] | |
| [] | |
| public string Destination { get; set; } | |
| [] | |
| [] | |
| [] | |
| public string Configuration { get; set; } | |
| protected override void EndProcessing() { } | |
| } | |
| public class DynamicParamOne | |
| { | |
| [] | |
| [] | |
| public string ConfigFile { get; set; } | |
| [] | |
| [] | |
| public string ConfigName { get; set; } | |
| } | |
| [] | |
| public class TestMyDynamicParamOneCommand : PSCmdlet, IDynamicParameters | |
| { | |
| [] | |
| public string Name { get; set; } | |
| public object GetDynamicParameters() | |
| { | |
| return Name == "Joe" ? new DynamicParamOne() : null; | |
| } | |
| protected override void EndProcessing() { } | |
| } | |
| public class DynamicParamTwo | |
| { | |
| [] | |
| [] | |
| [] | |
| public string ConfigFile { get; set; } | |
| [] | |
| [] | |
| [] | |
| public string ConfigName { get; set; } | |
| } | |
| [] | |
| public class TestMyDynamicParamTwoCommand : PSCmdlet, IDynamicParameters | |
| { | |
| [] | |
| public string Name { get; set; } | |
| public object GetDynamicParameters() | |
| { | |
| return Name == "Joe" ? new DynamicParamTwo() : null; | |
| } | |
| protected override void EndProcessing() { } | |
| } | |
| } | |