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


C# TokenReader.Get方法代碼示例

本文整理匯總了C#中StarryEyes.Filters.Parsing.TokenReader.Get方法的典型用法代碼示例。如果您正苦於以下問題:C# TokenReader.Get方法的具體用法?C# TokenReader.Get怎麽用?C# TokenReader.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在StarryEyes.Filters.Parsing.TokenReader的用法示例。


在下文中一共展示了TokenReader.Get方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetListValue

 private static ListMembers GetListValue(TokenReader reader)
 {
     reader.AssertGet(TokenType.Period);
     var user = reader.AssertGet(TokenType.Literal).Value;
     reader.AssertGet(TokenType.Period);
     string slug;
     var slugToken = reader.Get();
     switch (slugToken.Type)
     {
         case TokenType.String:
         case TokenType.Literal:
             slug = slugToken.Value;
             break;
         default:
             throw CreateUnexpectedTokenError(slugToken.Value, reader.RemainQuery);
     }
     return new ListMembers(user, slug);
 }
開發者ID:Mojopon,項目名稱:StarryEyes,代碼行數:18,代碼來源:QueryCompiler.cs

示例2: CompileFilters

 /// <summary>
 ///     Instantiate expression tree from tokens.
 /// </summary>
 private static FilterExpressionRoot CompileFilters(IEnumerable<Token> token)
 {
     var reader = new TokenReader(token);
     var op = CompileL0(reader);
     if (reader.IsRemainToken)
     {
         throw CreateUnexpectedTokenError(reader.Get().ToString(), reader.RemainQuery);
     }
     return new FilterExpressionRoot { Operator = op };
 }
開發者ID:Mojopon,項目名稱:StarryEyes,代碼行數:13,代碼來源:QueryCompiler.cs

示例3: CompileSources

 /// <summary>
 ///     Instantiate sources from tokens.
 /// </summary>
 private static IEnumerable<FilterSourceBase> CompileSources(IEnumerable<Token> token)
 {
     // filter
     // filter: "argument"
     // filter: "argument1", "argument2", ... -> filter: "argument1", filter: "argument2", ...
     var reader = new TokenReader(token);
     while (reader.IsRemainToken)
     {
         var filter = reader.Get();
         if (filter.Type != TokenType.Literal && filter.Type != TokenType.OperatorMultiple)
         {
             throw CreateUnexpectedTokenError(filter.Value, reader.RemainQuery);
         }
         Type fstype;
         if (!FilterSourceResolver.TryGetValue(filter.Value, out fstype))
         {
             throw new ArgumentException(
                 QueryCompilerResources.QueryUnknownFilterSource + " " +
                 filter.Value);
         }
         if (reader.IsRemainToken && reader.LookAhead().Type == TokenType.Collon) // with argument
         {
             reader.AssertGet(TokenType.Collon);
             do
             {
                 var argument = reader.AssertGet(TokenType.String);
                 yield return Activator.CreateInstance(fstype, argument.Value) as FilterSourceBase;
                 // separated by comma
                 if (reader.IsRemainToken)
                 {
                     reader.AssertGet(TokenType.Comma);
                 }
             } while (reader.IsRemainToken && reader.LookAhead().Type == TokenType.String);
         }
         else
         {
             yield return Activator.CreateInstance(fstype) as FilterSourceBase;
             if (reader.IsRemainToken)
             {
                 // filters are divided by comma
                 reader.AssertGet(TokenType.Comma);
             }
         }
     }
 }
開發者ID:karno,項目名稱:StarryEyes,代碼行數:48,代碼來源:QueryCompiler.cs

示例4: CompileSources

 /// <summary>
 ///     Instantiate sources from tokens.
 /// </summary>
 private static IEnumerable<FilterSourceBase> CompileSources(IEnumerable<Token> token)
 {
     // filter
     // filter: "argument"
     // filter: "argument1", "argument2", ... -> filter: "argument1", filter: "argument2", ...
     var reader = new TokenReader(token);
     while (reader.IsRemainToken)
     {
         var filter = reader.Get();
         if (filter.Type != TokenType.Literal && filter.Type != TokenType.OperatorMultiple)
         {
             throw new ArgumentException("このトークンは無効です: " + filter.Type +
                                         " (リテラルか \'*\' です。)");
         }
         Type fstype;
         if (!FilterSourceResolver.TryGetValue(filter.Value, out fstype))
             throw new ArgumentException("フィルタ ソースが一致しません: " + filter.Value);
         if (reader.IsRemainToken && reader.LookAhead().Type == TokenType.Collon) // with argument
         {
             reader.AssertGet(TokenType.Collon);
             do
             {
                 var argument = reader.AssertGet(TokenType.String);
                 yield return Activator.CreateInstance(fstype, argument.Value) as FilterSourceBase;
                 // separated by comma
                 if (reader.IsRemainToken)
                 {
                     reader.AssertGet(TokenType.Comma);
                 }
             } while (reader.IsRemainToken && reader.LookAhead().Type == TokenType.String);
         }
         else
         {
             yield return Activator.CreateInstance(fstype) as FilterSourceBase;
             if (reader.IsRemainToken)
             {
                 // filters are divided by comma
                 reader.AssertGet(TokenType.Comma);
             }
         }
     }
 }
開發者ID:Mojopon,項目名稱:StarryEyes,代碼行數:45,代碼來源:QueryCompiler.cs

示例5: CompileFilters

 /// <summary>
 ///     Instantiate expression tree from tokens.
 /// </summary>
 private static FilterExpressionRoot CompileFilters(IEnumerable<Token> token)
 {
     var reader = new TokenReader(token);
     var op = CompileL0(reader);
     if (reader.IsRemainToken)
         throw new FilterQueryException("不正なトークンです: " + reader.Get(), reader.RemainQuery);
     return new FilterExpressionRoot { Operator = op };
 }
開發者ID:sgfc,項目名稱:StarryEyes,代碼行數:11,代碼來源:QueryCompiler.cs


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