本文整理汇总了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;
}
示例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;
}