本文整理汇总了C#中System.IO.StringReader.Tokens方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.Tokens方法的具体用法?C# StringReader.Tokens怎么用?C# StringReader.Tokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringReader
的用法示例。
在下文中一共展示了StringReader.Tokens方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reads
public void Reads()
{
TextReader s = new StringReader (" pi (True 42 C 3.14159) e (Y 1 2 (/3 4) 4 2.71 ) ");
var categories = new Func<char?, char, bool>[] {
(_, c) => char.IsLetterOrDigit (c) || c == '.',
(_, c) => c == '+' || c == '-' || c == '*' || c == '/',
(_, c) => !char.IsWhiteSpace (c),
};
var reader = new TextValueReader (s.Tokens (categories));
TvrData1 a;
TvrData2 b;
string p, e;
reader.Read (out p)
.Read (out a)
.Read (out e)
.Read (out b);
Assert.AreEqual ("pi", p);
Assert.AreEqual ("e", e);
Assert.AreEqual (true, a.A);
Assert.AreEqual ((byte) 42, a.B);
Assert.AreEqual ('C', a.C);
Assert.AreEqual (3.14159, a.D);
Assert.AreEqual ("Y", b.F);
Assert.AreEqual (1, b.A);
Assert.AreEqual (2, b.B);
Assert.AreEqual ("3", b.O.left);
Assert.AreEqual ('/', b.O.op);
Assert.AreEqual ("4", b.O.right);
Assert.AreEqual (4, b.C);
Assert.AreEqual (2.71f, b.D);
}
示例2: Tokens_OptionsInvalid
public void Tokens_OptionsInvalid()
{
TextReader s = new StringReader ("");
s.Tokens ((TextReaderCodaOptions) (-1));
}
示例3: Tokens_FullCategoriesNull
public void Tokens_FullCategoriesNull()
{
TextReader s = new StringReader ("");
Func<char?, char, bool>[] categories = null;
IEnumerable<string> r = s.Tokens (TextReaderCodaOptions.None, categories);
Ignore (r);
}
示例4: Tokens_CategoriesEmpty
public void Tokens_CategoriesEmpty()
{
TextReader s = new StringReader ("");
Func<char?, char, bool>[] categories = new Func<char?, char, bool>[0];
IEnumerable<string> r = s.Tokens (categories);
Ignore (r);
}
示例5: Tokens_FullCategoriesEmpty
public void Tokens_FullCategoriesEmpty()
{
TextReader s = new StringReader ("");
Func<char?, char, bool>[] categories = new Func<char?, char, bool>[0];
IEnumerable<string> r = s.Tokens (TextReaderRocksOptions.None, categories);
}
示例6: Tokens_CategoriesNull
public void Tokens_CategoriesNull()
{
TextReader s = new StringReader ("");
Func<char?, char, bool>[] categories = null;
IEnumerable<string> r = s.Tokens (categories);
}