本文整理汇总了C#中System.IO.TextReader.ReadLines方法的典型用法代码示例。如果您正苦于以下问题:C# TextReader.ReadLines方法的具体用法?C# TextReader.ReadLines怎么用?C# TextReader.ReadLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.TextReader
的用法示例。
在下文中一共展示了TextReader.ReadLines方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static IEnumerable<GoogleCodeIssue> Parse(TextReader reader)
{
Debug.Assert(reader != null);
var firstLine = reader.ReadLine();
if (string.IsNullOrEmpty(firstLine))
return Enumerable.Empty<GoogleCodeIssue>();
var headers = ParseValues(firstLine).ToArray();
var bindings = Enum.GetNames(typeof(GoogleCodeIssue.IssueField))
.Select(n => Array.FindIndex(headers, h => n.Equals(h, StringComparison.OrdinalIgnoreCase)))
.Select(i => (Func<IEnumerable<string>, string>)(values => values.ElementAtOrDefault(i) ?? string.Empty))
.ToArray();
return //...
from line in reader.ReadLines()
let values = ParseValues(line).ToArray()
let id = ParseInteger(bindings[(int)GoogleCodeIssue.IssueField.Id](values), CultureInfo.InvariantCulture)
where id != null && id.Value > 0
let issue = new GoogleCodeIssue
{
Id = id.Value,
Type = bindings[(int)GoogleCodeIssue.IssueField.Type](values),
Status = bindings[(int)GoogleCodeIssue.IssueField.Status](values),
Milestone = bindings[(int)GoogleCodeIssue.IssueField.Milestone](values),
Priority = bindings[(int)GoogleCodeIssue.IssueField.Priority](values),
Stars = bindings[(int)GoogleCodeIssue.IssueField.Stars](values),
Owner = bindings[(int)GoogleCodeIssue.IssueField.Owner](values),
Summary = bindings[(int)GoogleCodeIssue.IssueField.Summary](values)
}
select issue;
}
示例2: ParseFileText
public static IEnumerable<VectorPairs> ParseFileText(TextReader stringReader)
{
return stringReader
.ReadLines()
.Skip(1)
.ChunkBySize(3)
.Select(problem => ParseProblem(problem[1], problem[2]));
}
示例3: Parse
/// <summary>
/// Parses the TZDB time zone info file from the given reader and merges its information
/// with the given database. The reader is not closed or disposed.
/// </summary>
/// <param name="reader">The reader to read.</param>
/// <param name="database">The database to fill.</param>
internal void Parse(TextReader reader, TzdbDatabase database)
{
string currentZone = null;
foreach (var line in reader.ReadLines())
{
currentZone = ParseLine(line, currentZone, database);
}
}
示例4: TryParseAsDynamic
public static bool TryParseAsDynamic(TextReader textReader, out object dynamicValue)
{
HRONDynamicParseError[] errors;
return HRONSerializer.TryParseDynamic(
int.MaxValue,
textReader.ReadLines().Select(s => s.ToSubString()),
out dynamicValue,
out errors
);
}
示例5: TryParse
public static bool TryParse(TextReader textReader, IVisitor visitor)
{
if (visitor == null)
{
return false;
}
var translatingVisitor = new TranslatingVisitor(visitor);
HRONSerializer.Parse(
int.MaxValue,
textReader.ReadLines().Select(s => s.ToSubString()),
translatingVisitor
);
return translatingVisitor.ErrorCount == 0;
}