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


C# IStringReader.PutBack方法代码示例

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


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

示例1: ParseDiffHeader

        private static FileDiff ParseDiffHeader(IStringReader reader, ChangeSetDetail merge)
        {
            string fileName = ParseFileName(reader.ReadLine());
            bool binary = false;

            while (!reader.Done)
            {
                string line = reader.ReadLine();
                if (line.StartsWith("@@", StringComparison.Ordinal))
                {
                    reader.PutBack(line.Length);
                    break;
                }
                else if (line.StartsWith("GIT binary patch", StringComparison.Ordinal))
                {
                    binary = true;
                }
            }

            if (binary)
            {
                // Skip binary files
                reader.ReadToEnd();
            }

            var diff = new FileDiff(fileName)
            {
                Binary = binary
            };

            // Skip files from merged changesets
            if (merge != null && merge.Files.ContainsKey(fileName))
            {
                return null;
            }

            return diff;
        }
开发者ID:GregPerez83,项目名称:kudu,代码行数:38,代码来源:GitExeRepository.cs

示例2: ParseDiffChunk

        internal static FileDiff ParseDiffChunk(IStringReader reader, ref ChangeSetDetail merge)
        {
            var diff = ParseDiffHeader(reader, merge);

            if (diff == null)
            {
                return null;
            }

            // Current diff range
            DiffRange currentRange = null;
            int? leftCounter = null;
            int? rightCounter = null;

            // Parse the file diff
            while (!reader.Done)
            {
                int? currentLeft = null;
                int? currentRight = null;
                string line = reader.ReadLine();

                if (line.Equals(@"\ No newline at end of file", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                bool isDiffRange = line.StartsWith("@@", StringComparison.Ordinal);
                ChangeType? changeType = null;

                if (line.StartsWith("+", StringComparison.Ordinal))
                {
                    changeType = ChangeType.Added;
                    currentRight = ++rightCounter;
                    currentLeft = null;
                }
                else if (line.StartsWith("-", StringComparison.Ordinal))
                {
                    changeType = ChangeType.Deleted;
                    currentLeft = ++leftCounter;
                    currentRight = null;
                }
                else if (IsCommitHeader(line))
                {
                    reader.PutBack(line.Length);
                    merge = ParseCommitAndSummary(reader);
                }
                else
                {
                    if (!isDiffRange)
                    {
                        currentLeft = ++leftCounter;
                        currentRight = ++rightCounter;
                    }
                    changeType = ChangeType.None;
                }

                if (changeType != null)
                {
                    var lineDiff = new LineDiff(changeType.Value, line);
                    if (!isDiffRange)
                    {
                        lineDiff.LeftLine = currentLeft;
                        lineDiff.RightLine = currentRight;
                    }

                    diff.Lines.Add(lineDiff);
                }

                if (isDiffRange)
                {
                    // Parse the new diff range
                    currentRange = DiffRange.Parse(line.AsReader());
                    leftCounter = currentRange.LeftFrom - 1;
                    rightCounter = currentRange.RightFrom - 1;
                }
            }

            return diff;
        }
开发者ID:GregPerez83,项目名称:kudu,代码行数:79,代码来源:GitExeRepository.cs


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