internal static DxfBlocksSection BlocksSectionFromBuffer(DxfCodePairBufferReader buffer) { var section = new DxfBlocksSection(); section.Clear(); while (buffer.ItemsRemain) { var pair = buffer.Peek(); if (DxfCodePair.IsSectionStart(pair)) { // done reading blocks, onto the next section break; } else if (DxfCodePair.IsSectionEnd(pair)) { // done reading blocks buffer.Advance(); // swallow (0, ENDSEC) break; } if (pair.Code != 0) { throw new DxfReadException("Expected new block.", pair); } buffer.Advance(); // swallow (0, CLASS) var block = DxfBlock.FromBuffer(buffer); if (block != null) { section.Blocks.Add(block); } } return(section); }