public override BrokenSourceData GetProcessedData(ProcessedDataPackage state)
        {
            BrokenSourceData sourceData = new BrokenSourceData();

            SourceDumpFilesInfo       sdfi  = new SourceDumpFilesInfo(state);
            BrokenSourceDumpFilesInfo bsdfi = new BrokenSourceDumpFilesInfo(state);

            Stream sourceStream       = sdfi.Open(FileAccess.Read);
            Stream binarySourceStream = bsdfi.Open(FileAccess.Read);

            if (sourceStream == null || binarySourceStream == null)
            {
                return(sourceData);
            }

            StreamReader source = new StreamReader(sourceStream);

            sourceData.PageSource           = source.ReadToEnd();
            sourceData.SourceFilename       = sdfi.GetFilename();
            sourceData.SourceBreaksFilename = bsdfi.GetFilename();
            source.Close();
            source.Dispose();

            BinaryReader sourceBreaks = new BinaryReader(binarySourceStream);

            MemoryStream ms = new MemoryStream();

            byte[] buffer = new byte[10];

            int startIndex = 0;
            int length     = 0;

            while (sourceBreaks.BaseStream.Position < sourceBreaks.BaseStream.Length)
            {
                for (int i = 0; i < buffer.Length; i++)
                {
                    buffer[i] = sourceBreaks.ReadByte();
                    ms.WriteByte(buffer[i]);
                }
                startIndex = buffer[2];
                startIndex = (startIndex << 8) | buffer[3];
                startIndex = (startIndex << 8) | buffer[4];
                startIndex = (startIndex << 8) | buffer[5];

                length = buffer[6];
                length = (length << 8) | buffer[7];
                length = (length << 8) | buffer[8];
                length = (length << 8) | buffer[9];

                sourceData.InjectionBreaks.AddLast(new SourcePiece(sourceData, startIndex, length));
            }

            sourceData.RawSourceBreaks = ms.ToArray();
            ms.Close();
            ms.Dispose();
            sourceBreaks.Close();

            return(sourceData);
        }
Esempio n. 2
0
        public override PageSourceData GetProcessedData(ProcessedDataPackage state)
        {
            SourceDumpFilesInfo sdfi = new SourceDumpFilesInfo(state);
            Stream sourceStream      = sdfi.Open(FileAccess.Read);

            PageSourceData sourceData = new PageSourceData();

            if (sourceStream == null)
            {
                return(sourceData);
            }

            StreamReader source = new StreamReader(sourceStream);

            sourceData.SourceFilename = sdfi.GetFilename();
            sourceData.PageSource     = source.ReadToEnd();
            source.Close();
            source.Dispose();

            return(sourceData);
        }