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


C# FileInRevision.CreateTempFile方法代码示例

本文整理汇总了C#中Chorus.VcsDrivers.Mercurial.FileInRevision.CreateTempFile方法的典型用法代码示例。如果您正苦于以下问题:C# FileInRevision.CreateTempFile方法的具体用法?C# FileInRevision.CreateTempFile怎么用?C# FileInRevision.CreateTempFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chorus.VcsDrivers.Mercurial.FileInRevision的用法示例。


在下文中一共展示了FileInRevision.CreateTempFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CollectChangesInFile

        private void CollectChangesInFile(FileInRevision fileInRevision, string parentRev, List<IChangeReport> changes)
        {
            var handler = _fileHandlerCollection.GetHandlerForDiff(fileInRevision.FullPath);
            //find, for example, a handler that can handle .lift dictionary, or a .wav sound file
            if (handler.CanDiffFile(fileInRevision.FullPath))//review: isn't that just asking again?
            {
                if (parentRev != null && fileInRevision.ActionThatHappened == FileInRevision.Action.Modified)
                {
                    var parentFileInRevision = new FileInRevision(parentRev, Path.Combine(Repository.PathToRepo, fileInRevision.FullPath),
                                                                  fileInRevision.ActionThatHappened);

                    //pull the files out of the repository so we can read them
            //                    using (var targetFile = fileInRevision.CreateTempFile(Repository))
            //                    using (var parentFile = parentFileInRevision.CreateTempFile(Repository))
                    {
                        //run the differ which the handler provides, adding the changes to the cumulative
                        //list we are gathering for this whole revision
                        changes.AddRange(handler.Find2WayDifferences(parentFileInRevision, fileInRevision, Repository));
                    }
                }
                else
                {
                    try
                    {
                        using (var targetFile = fileInRevision.CreateTempFile(Repository))
                        {
                            changes.AddRange(handler.DescribeInitialContents(fileInRevision, targetFile));
                        }
                    }
                    catch (Exception error)
                    {
                        changes.Add(new DefaultChangeReport(fileInRevision,
                                                            "Error retrieving historical version. "+error.Message));
                    }
                }
            }
            else
            {
                switch (fileInRevision.ActionThatHappened)
                {
                    case FileInRevision.Action.Added:
                        changes.Add(new DefaultChangeReport(fileInRevision, "Added"));
                        break;
                    case FileInRevision.Action.Modified:
                        var parentFileInRevision = new FileInRevision(parentRev, Path.Combine(Repository.PathToRepo, fileInRevision.FullPath),
                                                                      FileInRevision.Action.Parent);
                        changes.Add(new DefaultChangeReport(parentFileInRevision, fileInRevision, "Changed"));
                        break;
                    case FileInRevision.Action.Deleted:
                        changes.Add(new DefaultChangeReport(fileInRevision, "Deleted"));
                        break;
                    default:
                        Debug.Fail("Found unexpected FileInRevision Action.");
                        break;

                }
            }
        }
开发者ID:JessieGriffin,项目名称:chorus,代码行数:58,代码来源:RevisionInspector.cs


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