当前位置: 首页>>代码示例>>C#>>正文


C# ICommandContext.RegisterOutput方法代码示例

本文整理汇总了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;
            }          
        }
开发者ID:cg123,项目名称:xenko,代码行数:32,代码来源:FileOperationCommand.cs

示例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();
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:22,代码来源:IndexFileCommand.cs


注:本文中的ICommandContext.RegisterOutput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。