本文整理汇总了C#中Reader.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Reader.ToList方法的具体用法?C# Reader.ToList怎么用?C# Reader.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reader
的用法示例。
在下文中一共展示了Reader.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCheckIfs
public void TestCheckIfs()
{
const string testData = @"
A
#IF A B
C
#IF A
D
E
#FI
F
#IF B G
H
#IF B
I
J
#FI
K
#IF A
L
";
Reader reader = new Reader(new StringReader(testData)) {Options = {Selector = "A"}};
List<Line> lines = reader.ToList();
Assert.AreEqual(9, lines.Count, lines.Aggregate("", (x, y) => x + y.Content + ", "));
Assert.AreEqual("A", lines[0].Content);
Assert.AreEqual("B", lines[1].Content);
Assert.AreEqual("C", lines[2].Content);
Assert.AreEqual("D", lines[3].Content);
Assert.AreEqual("E", lines[4].Content);
Assert.AreEqual("F", lines[5].Content);
Assert.AreEqual("H", lines[6].Content);
Assert.AreEqual("K", lines[7].Content);
Assert.AreEqual("L", lines[8].Content);
reader = new Reader(new StringReader(testData)) {Options = {Selector = "B"}};
lines = reader.ToList();
Assert.AreEqual(8, lines.Count, lines.Aggregate("", (x, y) => x + y.Content + ", "));
Assert.AreEqual("A", lines[0].Content);
Assert.AreEqual("C", lines[1].Content);
Assert.AreEqual("F", lines[2].Content);
Assert.AreEqual("G", lines[3].Content);
Assert.AreEqual("H", lines[4].Content);
Assert.AreEqual("I", lines[5].Content);
Assert.AreEqual("J", lines[6].Content);
Assert.AreEqual("K", lines[7].Content);
}
示例2: TestIgnoreComments
public void TestIgnoreComments()
{
Reader reader = new Reader(new StringReader(@"
A
// B
C
/*
D
E
*/
/*
A
// C
*/
/* B */
F
// G
H
/* I */
I
/*
J
*/
K
"));
List<Line> lines = reader.ToList();
Assert.AreEqual(6, lines.Count());
Assert.AreEqual("A", lines[0].Content);
Assert.AreEqual("C", lines[1].Content);
Assert.AreEqual("F", lines[2].Content);
Assert.AreEqual("H", lines[3].Content);
Assert.AreEqual("I", lines[4].Content);
Assert.AreEqual("K", lines[5].Content);
}