當前位置: 首頁>>代碼示例>>C#>>正文


C# StringReader.Tokens方法代碼示例

本文整理匯總了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);
        }
開發者ID:mono,項目名稱:rocks,代碼行數:35,代碼來源:TextValueReaderTest.cs

示例2: Tokens_OptionsInvalid

 public void Tokens_OptionsInvalid()
 {
     TextReader s = new StringReader ("");
     s.Tokens ((TextReaderCodaOptions) (-1));
 }
開發者ID:rikkus,項目名稱:cadenza,代碼行數:5,代碼來源:TextReaderCodaTest.cs

示例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);
 }
開發者ID:rikkus,項目名稱:cadenza,代碼行數:7,代碼來源:TextReaderCodaTest.cs

示例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);
 }
開發者ID:rikkus,項目名稱:cadenza,代碼行數:7,代碼來源:TextReaderCodaTest.cs

示例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);
 }
開發者ID:mono,項目名稱:rocks,代碼行數:6,代碼來源:TextReaderTest.cs

示例6: Tokens_CategoriesNull

 public void Tokens_CategoriesNull()
 {
     TextReader                         s = new StringReader ("");
     Func<char?, char, bool>[] categories = null;
     IEnumerable<string>                r = s.Tokens (categories);
 }
開發者ID:mono,項目名稱:rocks,代碼行數:6,代碼來源:TextReaderTest.cs


注:本文中的System.IO.StringReader.Tokens方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。