本文整理匯總了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);
}