【发布时间】:2013-06-06 19:08:44
【问题描述】:
我正在用 C# 编写一个 cmdlet。为了让我的 cmdlet 正常工作,我需要初始化许多东西。
我是通过覆盖 BeginProcessing 还是在默认的类构造函数中进行初始化?
精简示例:
[Cmdlet(VerbsCommon.Set, "MyNoun")]
class MyCmdlet : PSCmdlet
{
string s;
[Parameter(Position = 0, Mandatory = true)]
public string whatever;
public MyCmdlet()
{
//initialize s here?
}
public override void BeginProcessing()
{
//or initialize s here?
}
}
【问题讨论】:
标签: c# powershell-cmdlet