当前位置: 首页>>代码示例>>C#>>正文


C# ParseContext.AdvanceInput方法代码示例

本文整理汇总了C#中ParseContext.AdvanceInput方法的典型用法代码示例。如果您正苦于以下问题:C# ParseContext.AdvanceInput方法的具体用法?C# ParseContext.AdvanceInput怎么用?C# ParseContext.AdvanceInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParseContext的用法示例。


在下文中一共展示了ParseContext.AdvanceInput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetLanguage

        protected string GetLanguage(ParseContext context)
        {
            var languageBuilder = new StringBuilder();
            context.AdvanceInput();
            while (context.CurrentChar != '\n' && context.CurrentChar != ButterflyStringReader.NoValue) {
                languageBuilder.Append((char)context.CurrentChar);
                context.AdvanceInput();
            }

            return languageBuilder.ToString();
        }
开发者ID:tmont,项目名称:butterfly,代码行数:11,代码来源:OpenPreformattedStrategy.cs

示例2: DoExecute

        protected override void DoExecute(ParseContext context)
        {
            IScope rowScope = new TableRowLineScope();
            if (context.Input.Peek() == '{') {
                context.AdvanceInput();
                rowScope = new TableRowScope();
            }

            var cellType = ScopeTypeCache.TableCell;
            if (context.Input.Peek() == '!') {
                context.AdvanceInput();
                cellType = ScopeTypeCache.TableHeader;
            }

            context.Input.SeekToNonWhitespace();
            context.UpdateCurrentChar();

            if (!context.Scopes.ContainsType(ScopeTypeCache.Table)) {
                //no tables, so create a new one
                OpenScope(new TableScope(), context);
                OpenScope(rowScope, context);
            } else if (context.Scopes.ContainsType(ScopeTypeCache.TableCell, ScopeTypeCache.TableHeader)) {
                //close table cell
                var currentScope = context.Scopes.PeekOrDefault();
                if (currentScope == null || (currentScope.GetType() != ScopeTypeCache.TableCell && currentScope.GetType() != ScopeTypeCache.TableHeader)) {
                    throw new ParseException("Cannot close table cell until all containing scopes are closed");
                }

                CloseCurrentScope(context);
            } else if (!context.Scopes.ContainsType(ScopeTypeCache.TableRow, ScopeTypeCache.TableRowLine)) {
                OpenScope(rowScope, context);
            }

            //figure out if we need to open a new cell or not
            //criteria:
            // - not EOL
            // - we're in a row terminated by a line break and the next char is not a new line (signifying a new row)
            // - OR we're in a row not terminated by a line break
            if (
                context.Input.Peek() != ButterflyStringReader.NoValue && (
                    (context.Scopes.ContainsType(ScopeTypeCache.TableRowLine) && context.Input.Peek() != '\n')
                    || context.Scopes.ContainsType(ScopeTypeCache.TableRow)
                )
            ) {
                OpenScope(cellType == ScopeTypeCache.TableHeader ? (IScope)new TableHeaderScope() : new TableCellScope(), context);
            }
        }
开发者ID:tmont,项目名称:butterfly,代码行数:47,代码来源:TableStrategy.cs


注:本文中的ParseContext.AdvanceInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。