private void Aggregate(BlockAggregateContext context)
 {
     while (context.NextBlock())
     {
         _aggregator.Aggregate(context);
     }
 }
示例#2
0
        public bool Aggregate(BlockAggregateContext context)
        {
            if (context.CurrentBlock is TBlock block)
            {
                return(AggregateCore(block, context));
            }

            return(false);
        }
示例#3
0
        public bool Aggregate(BlockAggregateContext context)
        {
            var block = context.CurrentBlock as TBlock;

            if (block != null)
            {
                return(AggregateCore(block, context));
            }

            return(false);
        }
        private void VisitContainerBlock(ContainerBlock blocks)
        {
            for (var i = 0; i < blocks.Count; i++)
            {
                var block = blocks[i];
                if (block is ContainerBlock containerBlock)
                {
                    VisitContainerBlock(containerBlock);
                }

                var context = new BlockAggregateContext(blocks);
                Aggregate(context);
            }
        }
示例#5
0
        protected override bool AggregateCore(HeadingBlock headBlock, BlockAggregateContext context)
        {
            var pair = ParseHeading(headBlock);

            if (pair == null)
            {
                return(false);
            }
            int offset = 1;
            var items  = new List <TabItemBlock>();
            var list   = new List <Block>();

            while (true)
            {
                var block = context.LookAhead(offset);
                switch (block)
                {
                case HeadingBlock head:
                    var temp = ParseHeading(head);
                    if (temp == null)
                    {
                        goto default;
                    }
                    items.Add(CreateTabItem(headBlock, pair, list, ref offset));
                    pair = temp;
                    list.Clear();
                    break;

                case ThematicBreakBlock hr:
                    offset++;
                    list.Add(block);
                    goto case null;

                case null:
                    items.Add(CreateTabItem(headBlock, pair, list, ref offset));
                    var startLine = headBlock.Line;
                    var startSpan = headBlock.Span.Start;
                    AggregateCore(context, items, startLine, startSpan, offset);
                    return(true);

                default:
                    list.Add(block);
                    break;
                }
                offset++;
            }
        }
示例#6
0
        private static void AggregateCore(
            BlockAggregateContext context,
            List <TabItemBlock> items,
            int startLine,
            int startSpan,
            int offset
            )
        {
            var groupId = (items[0]?.Content?.ToString() ?? string.Empty).GetMd5String().Replace("/", "-").Remove(10);

            context.AggregateTo(new TabGroupBlock(
                                    groupId,
                                    items.ToImmutableArray(),
                                    startLine,
                                    startSpan,
                                    0),
                                offset);
        }
示例#7
0
 protected abstract bool AggregateCore(TBlock block, BlockAggregateContext context);