本文整理汇总了C#中ICommandContext.RegisterOutput方法的典型用法代码示例。如果您正苦于以下问题:C# ICommandContext.RegisterOutput方法的具体用法?C# ICommandContext.RegisterOutput怎么用?C# ICommandContext.RegisterOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICommandContext
的用法示例。
在下文中一共展示了ICommandContext.RegisterOutput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoCommandOverride
protected override async Task<ResultStatus> DoCommandOverride(ICommandContext commandContext)
{
try
{
switch (Type)
{
case Operation.Move:
if (File.Exists(Target))
File.Delete(Target);
File.Move(Source, Target);
commandContext.RegisterOutput(new ObjectUrl(UrlType.File, Target), ObjectId.Empty);
break;
case Operation.Copy:
var sourceStream = File.OpenRead(Source);
var destStream = File.OpenWrite(Target);
await sourceStream.CopyToAsync(destStream);
commandContext.RegisterOutput(new ObjectUrl(UrlType.File, Target), ObjectId.Empty);
break;
case Operation.Delete:
File.Delete(Source);
break;
}
return ResultStatus.Successful;
}
catch (Exception e)
{
commandContext.Logger.Error(e.Message);
return ResultStatus.Failed;
}
}
示例2: PostCommand
public override void PostCommand(ICommandContext commandContext, ResultStatus status)
{
base.PostCommand(commandContext, status);
if (status == ResultStatus.Successful)
{
// Save list of newly changed URLs in CommandResult.OutputObjects
foreach (var entry in buildTransaction.GetTransactionIdMap())
{
commandContext.RegisterOutput(entry.Key, entry.Value);
}
// Note: In case of remote process, the remote process will save the index map.
// Alternative would be to not save it and just forward results to the master builder who would commit results locally.
// Not sure which is the best.
//
// Anyway, current approach should be OK for now since the index map is "process-safe" (as long as we load new values as necessary).
//contentIndexMap.Save();
}
MicrothreadLocalDatabases.UnmountDatabase();
}