本文整理汇总了C#中IStringReader类的典型用法代码示例。如果您正苦于以下问题:C# IStringReader类的具体用法?C# IStringReader怎么用?C# IStringReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStringReader类属于命名空间,在下文中一共展示了IStringReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VerifyInitialState
private static void VerifyInitialState(IStringReader reader)
{
Assert.IsNotNull(reader);
Assert.AreEqual(char.MinValue, reader.CurrentChar);
Assert.IsFalse(reader.IsEof);
Assert.IsFalse(reader.IsEmpty);
Assert.AreEqual(0, reader.Line);
Assert.AreEqual(-1, reader.LineOffset);
}
开发者ID:phofman,项目名称:codetitans-libs,代码行数:9,代码来源:StringReaderTests.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
示例3: ReadWhiteChars
/// <summary>
/// Reads from the current input stream all the whitespaces.
/// </summary>
internal static StringHelperStatusCode ReadWhiteChars(IStringReader reader, out int count)
{
count = 0;
do
{
char currentChar = reader.ReadNext();
if (reader.IsEof)
return StringHelperStatusCode.UnexpectedEoF;
if (!char.IsWhiteSpace(currentChar))
break;
count++;
}
while (true);
return StringHelperStatusCode.Success;
}
开发者ID:phofman,项目名称:codetitans-libs,代码行数:23,代码来源:StringHelper.cs
示例4: VerifyEmptyReadingByLines
private static void VerifyEmptyReadingByLines(IStringReader reader)
{
Assert.IsNotNull(reader);
Assert.IsTrue(reader.IsEmpty);
Assert.AreEqual(null, reader.ReadLine());
Assert.AreEqual(0, reader.Line);
Assert.AreEqual(-1, reader.LineOffset);
Assert.AreEqual(char.MinValue, reader.CurrentChar);
}
开发者ID:phofman,项目名称:codetitans-libs,代码行数:9,代码来源:StringReaderTests.cs
示例5: ParseShow
private static ChangeSetDetail ParseShow(IStringReader reader, bool includeChangeSet = true)
{
ChangeSetDetail detail = null;
if (includeChangeSet)
{
detail = ParseCommitAndSummary(reader);
}
else
{
detail = new ChangeSetDetail();
ParseSummary(reader, detail);
}
ParseDiffAndPopulate(reader, detail);
return detail;
}
开发者ID:GregPerez83,项目名称:kudu,代码行数:17,代码来源:GitExeRepository.cs
示例6: Parse
public static DiffRange Parse(IStringReader reader)
{
var range = new DiffRange();
reader.Skip("@@");
reader.SkipWhitespace();
reader.Skip('-');
range.LeftFrom = reader.ReadInt();
if (reader.Skip(','))
{
range.LeftTo = range.LeftFrom + reader.ReadInt();
}
else
{
range.LeftTo = range.LeftFrom;
}
reader.SkipWhitespace();
reader.Skip('+');
range.RightFrom = reader.ReadInt();
if (reader.Skip(','))
{
range.RightTo = range.RightFrom + reader.ReadInt();
}
else
{
range.RightTo = range.RightFrom;
}
reader.SkipWhitespace();
reader.Skip("@@");
return range;
}
开发者ID:GregPerez83,项目名称:kudu,代码行数:30,代码来源:GitExeRepository.cs
示例7: Parse
private static int Parse(IStringReader input, object o, string startTag, string endTag, Callback onText, Callback onMarker)
{
if (input == null)
throw new ArgumentNullException("input");
if (string.IsNullOrEmpty(startTag))
throw new ArgumentNullException("startTag");
if (string.IsNullOrEmpty(endTag))
throw new ArgumentNullException("endTag");
if (onText == null && onMarker == null)
throw new ArgumentNullException("onText");
if (input.IsEmpty)
return 0;
string line;
string substring;
int processingStart;
int startIndex;
int endIndex;
int result = 0;
StringBuilder text = new StringBuilder();
StringBuilder content = new StringBuilder();
bool insideTag = false;
bool continueProcessing;
while ((line = input.ReadLine()) != null)
{
processingStart = 0;
do
{
// is there any tag in current line:
startIndex = insideTag ? -1 : line.IndexOf(startTag, processingStart, StringComparison.Ordinal);
continueProcessing = false;
if (startIndex < 0)
{
if (insideTag)
{
endIndex = line.IndexOf(endTag, processingStart, StringComparison.Ordinal);
if (endIndex < 0)
{
// add content of the tag
content.Append(processingStart > 0 ? line.Substring(processingStart) : line).Append("\r\n");
}
else
{
// was there any text before
if (text.Length > 0)
{
if (onText != null)
onText(o, text.ToString());
#if NET_2_COMPATIBLE || SILVERLIGHT
text.Remove(0, text.Length);
#else
text.Clear();
#endif
}
// append beginning as a tag
if (content.Length > 0)
{
substring = content.Append(line.Substring(processingStart, endIndex - processingStart)).ToString();
#if NET_2_COMPATIBLE || SILVERLIGHT
content.Remove(0, content.Length);
#else
content.Clear();
#endif
}
else
{
substring = line.Substring(processingStart, endIndex - processingStart);
}
if (onMarker != null)
onMarker(o, substring);
result++;
insideTag = false;
continueProcessing = true;
processingStart = endIndex + endTag.Length;
}
}
else
{
// add the whole line into the buffer, so we minimize the number of notifications
text.Append(processingStart > 0 ? line.Substring(processingStart) : line);
if (!input.IsEof)
text.Append("\r\n");
}
}
else
{
// text before tag
if (startIndex > processingStart || text.Length > 0)
{
if (text.Length > 0)
//.........这里部分代码省略.........
开发者ID:phofman,项目名称:codetitans-libs,代码行数:101,代码来源:MarkerStrings.cs
示例8: PopulateStatus
internal static void PopulateStatus(IStringReader reader, ChangeSetDetail detail)
{
while (!reader.Done)
{
string line = reader.ReadLine();
// Status lines contain tabs
if (!line.Contains("\t"))
{
continue;
}
var lineReader = line.AsReader();
string status = lineReader.ReadUntilWhitespace();
lineReader.SkipWhitespace();
string name = lineReader.ReadToEnd().TrimEnd();
lineReader.SkipWhitespace();
FileInfo file;
if (detail.Files.TryGetValue(name, out file))
{
file.Status = ConvertStatus(status);
}
}
}
开发者ID:GregPerez83,项目名称:kudu,代码行数:22,代码来源:GitExeRepository.cs
示例9: ReadCommentChars
internal static StringHelperStatusCode ReadCommentChars(IStringReader reader, bool multiline)
{
if (multiline)
{
char previousChar;
char currentChar = '\0';
do
{
previousChar = currentChar;
currentChar = reader.ReadNext();
if (reader.IsEof)
return StringHelperStatusCode.UnexpectedEoF;
if (previousChar == '*' && currentChar == '/')
return StringHelperStatusCode.Success;
}
while (true);
}
else
{
do
{
var currentChar = reader.ReadNext();
if (reader.IsEof)
return StringHelperStatusCode.UnexpectedEoF;
if (currentChar == '\r' || currentChar == '\n')
return StringHelperStatusCode.Success;
}
while (true);
}
}
开发者ID:phofman,项目名称:codetitans-libs,代码行数:34,代码来源:StringHelper.cs
示例10: Reset
/// <summary>
/// Returns reader to the original state.
/// </summary>
private void Reset(IStringReader input, bool returnJSonObject)
{
if (input == null)
throw new ArgumentNullException("input");
_input = input;
_tokens = new Stack<JSonReaderTokenInfo>();
_getTokenFromStack = false;
if (returnJSonObject)
_factory = new JSonObjectFactory();
else
_factory = new FclObjectFactory();
}
开发者ID:serchuz,项目名称:Groove-Down,代码行数:16,代码来源:JSonReader.cs
示例11: ReadKeywordChars
/// <summary>
/// Reads the keyword definition chars from given input.
/// </summary>
internal static StringHelperStatusCode ReadKeywordChars(IStringReader reader, StringBuilder output)
{
do
{
var currentChar = reader.ReadNext();
if (char.IsLetter(currentChar))
{
output.Append(currentChar);
}
else
break;
}
while (true);
return StringHelperStatusCode.Success;
}
开发者ID:phofman,项目名称:codetitans-libs,代码行数:20,代码来源:StringHelper.cs
示例12: ReadStringChars
/// <summary>
/// Reads the string from given input stream.
/// </summary>
internal static StringHelperStatusCode ReadStringChars(IStringReader reader, StringBuilder output, StringBuilder escapedUnicodeNumberBuffer, bool errorOnNewLine, out int lastLine, out int lastOffset)
{
bool escape = false;
bool unicodeNumber = false;
if (escapedUnicodeNumberBuffer == null)
escapedUnicodeNumberBuffer = new StringBuilder();
lastLine = reader.Line;
lastOffset = reader.LineOffset;
do
{
if (!unicodeNumber)
{
lastLine = reader.Line;
lastOffset = reader.LineOffset;
}
var currentChar = reader.ReadNext();
// verify if not an invalid character was found in text:
if (reader.IsEof)
return StringHelperStatusCode.UnexpectedEoF;
if (errorOnNewLine && (currentChar == '\r' || currentChar == '\n'))
return StringHelperStatusCode.UnexpectedNewLine;
if (unicodeNumber)
{
StringHelperStatusCode result = ReadStringUnicodeCharacter(currentChar, output, escapedUnicodeNumberBuffer, out unicodeNumber);
// if parsing Unicode character failed, immediatelly stop!
if (result != StringHelperStatusCode.Success)
return result;
continue;
}
if (currentChar == '\\' && !escape)
{
escape = true;
}
else
{
if (escape)
{
switch (currentChar)
{
case 'n':
output.Append('\n');
break;
case 'r':
output.Append('\r');
break;
case 't':
output.Append('\t');
break;
case '/':
output.Append('/');
break;
case '\\':
output.Append('\\');
break;
case 'f':
output.Append('\f');
break;
case 'U':
case 'u':
unicodeNumber = true;
break;
case '"':
output.Append('"');
break;
case '\'':
output.Append('\'');
break;
default:
return StringHelperStatusCode.UnknownEscapedChar;
}
escape = false;
}
else
{
if (currentChar == '"')
break;
output.Append(currentChar);
}
}
}
while (true);
// as the string might finish with a Unicode character...
if (unicodeNumber)
return AddUnicodeChar(output, escapedUnicodeNumberBuffer, false);
//.........这里部分代码省略.........
开发者ID:phofman,项目名称:codetitans-libs,代码行数:101,代码来源:StringHelper.cs
示例13: ReadIntegerNumberChars
/// <summary>
/// Reads characters that might be a number and copies them to given output.
/// </summary>
internal static StringHelperStatusCode ReadIntegerNumberChars(IStringReader reader, StringBuilder output)
{
do
{
var currentChar = reader.ReadNext();
if (char.IsDigit(currentChar) || currentChar == '-' || currentChar == '+')
{
output.Append(currentChar);
}
else
break;
}
while (true);
return StringHelperStatusCode.Success;
}
开发者ID:phofman,项目名称:codetitans-libs,代码行数:20,代码来源:StringHelper.cs
示例14: ParseStatus
internal static IEnumerable<FileStatus> ParseStatus(IStringReader reader)
{
reader.SkipWhitespace();
while (!reader.Done)
{
var subReader = reader.ReadLine().AsReader();
string status = subReader.ReadUntilWhitespace().Trim();
string path = subReader.ReadLine().Trim();
yield return new FileStatus(path, ConvertStatus(status));
reader.SkipWhitespace();
}
}
开发者ID:GregPerez83,项目名称:kudu,代码行数:13,代码来源:GitExeRepository.cs
示例15: ParseSummary
internal static void ParseSummary(IStringReader reader, ChangeSetDetail detail)
{
reader.SkipWhitespace();
while (!reader.Done)
{
string line = reader.ReadLine();
if (ParserHelpers.IsSingleNewLine(line))
{
break;
}
else if (line.Contains('\t'))
{
// n n path
string[] parts = line.Split('\t');
int insertions;
Int32.TryParse(parts[0], out insertions);
int deletions;
Int32.TryParse(parts[1], out deletions);
string path = parts[2].TrimEnd();
detail.Files[path] = new FileInfo
{
Insertions = insertions,
Deletions = deletions,
Binary = parts[0] == "-" && parts[1] == "-"
};
}
else
{
// n files changed, n insertions(+), n deletions(-)
ParserHelpers.ParseSummaryFooter(line, detail);
}
}
}
开发者ID:GregPerez83,项目名称:kudu,代码行数:36,代码来源:GitExeRepository.cs
示例16: ParseSummary
internal static void ParseSummary(IStringReader reader, ChangeSetDetail detail)
{
while (!reader.Done)
{
string line = reader.ReadLine();
if (line.Contains('|'))
{
string[] parts = line.Split('|');
string path = parts[0].Trim();
// TODO: Figure out a way to get this information
detail.Files[path] = new FileInfo();
}
else
{
// n files changed, n insertions(+), n deletions(-)
ParserHelpers.ParseSummaryFooter(line, detail);
}
}
}
开发者ID:JayQuerido,项目名称:kudu,代码行数:20,代码来源:HgRepository.cs
示例17: 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
示例18: ParseCommit
internal static ChangeSet ParseCommit(IStringReader reader)
{
// commit hash
reader.ReadUntilWhitespace();
reader.SkipWhitespace();
string id = reader.ReadUntilWhitespace();
// Merges will have (from hash) so we're skipping that
reader.ReadLine();
string author = null;
string email = null;
string date = null;
while (!reader.Done)
{
string line = reader.ReadLine();
if (ParserHelpers.IsSingleNewLine(line))
{
break;
}
var subReader = line.AsReader();
string key = subReader.ReadUntil(':');
// Skip :
subReader.Skip();
subReader.SkipWhitespace();
string value = subReader.ReadToEnd().Trim();
if (key.Equals("Author", StringComparison.OrdinalIgnoreCase))
{
// Author <email>
var authorReader = value.AsReader();
author = authorReader.ReadUntil('<').Trim();
authorReader.Skip();
email = authorReader.ReadUntil('>');
}
else if (key.Equals("Date", StringComparison.OrdinalIgnoreCase))
{
date = value;
}
}
var messageBuilder = new StringBuilder();
while (!reader.Done)
{
string line = reader.ReadLine();
if (ParserHelpers.IsSingleNewLine(line))
{
break;
}
messageBuilder.Append(line);
}
string message = messageBuilder.ToString();
return new ChangeSet(id, author, email, message, DateTimeOffset.ParseExact(date, "ddd MMM d HH:mm:ss yyyy zzz", CultureInfo.InvariantCulture));
}
开发者ID:GregPerez83,项目名称:kudu,代码行数:59,代码来源:GitExeRepository.cs
示例19: ParseCommits
private IEnumerable<ChangeSet> ParseCommits(IStringReader reader)
{
while (!reader.Done)
{
yield return ParseCommit(reader);
}
}
开发者ID:GregPerez83,项目名称:kudu,代码行数:7,代码来源:GitExeRepository.cs
示例20: ParseCommitAndSummary
internal static ChangeSetDetail ParseCommitAndSummary(IStringReader reader)
{
// Parse the changeset
ChangeSet changeSet = ParseCommit(reader);
var detail = new ChangeSetDetail(changeSet);
ParseSummary(reader, detail);
return detail;
}
开发者ID:GregPerez83,项目名称:kudu,代码行数:11,代码来源:GitExeRepository.cs
注:本文中的IStringReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论