Exemple #1
0
        /// <summary>
        /// Visit all blocks
        /// </summary>
        /// <param name="block"></param>
        /// <param name="onBlockEnter">Called when enters a block</param>
        /// <param name="onBlockLeave">Called when leaves a block</param>
        /// <returns></returns>
        public static int Visit(Block block, BlockHandler?onBlockEnter = null, BlockHandler?onBlockLeave = null)
        {
            var visitor = new BlockVisitor(onBlockEnter, onBlockLeave);

            visitor.VisitCore(block);
            return(visitor._count);
        }
Exemple #2
0
        /// <summary>
        /// Visit all blocks
        /// </summary>
        /// <param name="blocks"></param>
        /// <param name="onBlockEnter">Called when enters a block</param>
        /// <param name="onBlockLeave">Called when leaves a block</param>
        /// <returns></returns>
        public static int Visit(IEnumerable <Block> blocks, BlockHandler?onBlockEnter = null, BlockHandler?onBlockLeave = null)
        {
            var visitor = new BlockVisitor(onBlockEnter, onBlockLeave);

            visitor.VisitCore(blocks);
            return(visitor._count);
        }
Exemple #3
0
        /// <summary>
        /// Formats a block
        /// </summary>
        /// <param name="block"></param>
        /// <returns></returns>
        public static string Format_NoLock(Block block)
        {
            if (block is null)
            {
                throw new ArgumentNullException(nameof(block));
            }

            var formatter = new BlockFormatter();

#if !DEBUG
            formatter.SetBlockIds(block);
#endif
            BlockVisitor.Visit(block, formatter.OnBlockEnter, formatter.OnBlockLeave);
            return(formatter._buffer.ToString());
        }