Created
March 2, 2014 16:51
-
-
Save tanaka-takayoshi/9309470 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Management.Automation; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace MyCmdlets | |
{ | |
[Cmdlet(VerbsCommon.Get, "Greeting")] | |
public class GetGreeting : Cmdlet | |
{ | |
[Parameter(Position = 0, ValueFromPipeline = true)] | |
[ValidateNotNullOrEmpty] | |
public string Name { get; set; } | |
[Parameter(Position = 1)] | |
[ValidateSet("さん", "様", "殿")] | |
public string Title { get; set; } | |
protected override void BeginProcessing() | |
{ | |
WriteObject("Begin Hello World!"); | |
} | |
protected override void ProcessRecord() | |
{ | |
WriteObject(Name + " " + Title); | |
} | |
protected override void EndProcessing() | |
{ | |
WriteObject("End Hello World!"); | |
} | |
protected override void StopProcessing() | |
{ | |
//出力されない | |
WriteObject("Now stopping..."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment