Ejemplo n.º 1
0
        public StringBuilder WriteAllOverflowBlocks()
        {
            var builder = new StringBuilder(_overflowFile.MaxFileIndex + 3);

            builder.AppendLine($"Max overflow file block index: {_overflowFile.MaxFileIndex}");
            builder.AppendLine($"Max records in one overflow block: {MaxRecordsInOverflow}");
            builder.AppendLine("Free overflow blocks: " + _freeBlocksOverflow.ListToString(';'));
            builder.AppendLine();

            _workingBlock1 = new Block <T>(MaxRecordsInOverflow); //just to clear it
            var validIndex = 0;

            foreach (var byteData in _overflowFile.BlocksSequence())
            {
                _workingBlock1.FromByteArray(byteData);
                if (_workingBlock1.ValidCount > 0 && !_freeBlocksOverflow.Contains(validIndex))
                {
                    builder.AppendLine($"Current block index: {validIndex}, address: {validIndex * _workingBlock1.GetSize()}");
                    builder.AppendLine(_workingBlock1.ToString());
                }
                else
                {
                    builder.AppendLine($"Current block index: {validIndex}, address: {validIndex * _workingBlock1.GetSize()} IS NOT VALID!!");
                }

                validIndex++;
            }

            return(builder);
        }
Ejemplo n.º 2
0
        public StringBuilder WriteAllBlocks()
        {
            var builder = new StringBuilder(_file.MaxFileIndex + 4);

            builder.AppendLine($"Max block index: {_file.MaxFileIndex}");
            builder.AppendLine($"Max records in one block: {MaxRecords}");
            builder.AppendLine("Not full yet: " + _partiallyFullBlocks.ListToString(';'));
            builder.AppendLine("Free blocks: " + _freeBlocks.ListToString(';'));
            builder.AppendLine();

            _workingBlock = new Block <T>(MaxRecords); //just to clear it
            var validIndex = 0;

            foreach (var byteData in _file.BlocksSequence())
            {
                _workingBlock.FromByteArray(byteData);
                if (_workingBlock.ValidCount > 0 && !_freeBlocks.Contains(validIndex))
                {
                    builder.AppendLine($"Current block index: {validIndex}, address: {validIndex * _workingBlock.GetSize()}");
                    builder.AppendLine(_workingBlock.ToString());
                }
                else
                {
                    builder.AppendLine($"Current block index: {validIndex}, address: {validIndex * _workingBlock.GetSize()} IS NOT VALID!!");
                }

                validIndex++;
            }

            return(builder);
        }