本文整理汇总了C#中Action.ValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# Action.ValueOrDefault方法的具体用法?C# Action.ValueOrDefault怎么用?C# Action.ValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Action
的用法示例。
在下文中一共展示了Action.ValueOrDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallChocolatey
public virtual Task<int> InstallChocolatey(Action<string> outputAction, Action<string> errorAction)
{
outputAction = outputAction.ValueOrDefault();
errorAction = errorAction.ValueOrDefault();
var arguments = @"/c @powershell -NoProfile -ExecutionPolicy unrestricted -Command ""iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin";
return processRunner.RunProcess("cmd.exe", arguments, outputAction, errorAction);
}
示例2: Run
public async Task Run(string command, Dictionary<string, object> parameters, Action<string> logOutput, Action<string> logWarning, Action<string> logError, Action<ProgressRecord> logProgress)
{
if (currentPipeline !=null)
{
throw new Exception("Not thread safe");
}
currentPipeline = runSpace.CreatePipeline();
LogOutput = logOutput.ValueOrDefault();
LogWarning = logWarning.ValueOrDefault();
LogError = logError.ValueOrDefault();
LogProgress = logProgress.ValueOrDefault();
var psCommand = GetCommand(command, parameters);
currentPipeline.Commands.Add(psCommand);
var executableString = psCommand.ToExecutableString();
logOutput(executableString);
LogTo.Information("Executing powershell command: " + executableString);
await TaskEx.Run(() => ExecuteCommand());
}