RedisRipper.Workbench.WorkbenchFile.LoadSectionFromReader C# (CSharp) Méthode

LoadSectionFromReader() private méthode

private LoadSectionFromReader ( StreamReader reader, int expectedSize, CompanionFileType fileType ) : byte[]
reader System.IO.StreamReader
expectedSize int
fileType CompanionFileType
Résultat byte[]
        private byte[] LoadSectionFromReader(StreamReader reader, int expectedSize, CompanionFileType fileType)
        {
            List<byte> data = new List<byte>();

            int bytesRead = 0;

            while (bytesRead < expectedSize && !reader.EndOfStream)
            {
                string line = reader.ReadLine();
                line = line.Replace('é', 'e');

                List<byte> lineBytes = ParseLine(line);

                // Special Handling
                // RNAM - If the row appears filled with 0x255, make it a blank row.
                //    "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ","ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ",0,0,0,0,0,0
                //
                if (fileType == CompanionFileType.RNAM)
                {
                    if (lineBytes.Count == 114)
                    { // .net reads as UTF8, so a byte comparison is iffy. The row will be expanded to 114 UTF8 bytes when it is bad.
                        lineBytes = new List<byte> { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 0, 0, 0, 0, 0, 0 };
                    }
                }

                // probably have to add PAGR and REMS as well.

                data.AddRange(lineBytes);
                bytesRead += lineBytes.Count;
            }

            return data.ToArray();
        }