/// <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); }
/// <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); }