Beispiel #1
0
        public override void Encode()
        {
            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);

            NumStrings = StringList.Count;
            writer.Write(TotalOccurance);
            writer.Write(NumStrings);
            this.ContinuedRecords.Clear();
            Record currentRecord = this;

            foreach (String stringVar in StringList)
            {
                int stringlength = Record.GetStringDataLength(stringVar);
                if (stream.Length + stringlength > Record.MaxContentLength)
                {
                    currentRecord.Data = stream.ToArray();
                    currentRecord.Size = (UInt16)currentRecord.Data.Length;

                    stream = new MemoryStream();
                    writer = new BinaryWriter(stream);

                    CONTINUE continuedRecord = new CONTINUE();
                    this.ContinuedRecords.Add(continuedRecord);
                    currentRecord = continuedRecord;
                }
                Record.WriteString(writer, stringVar, 16);
            }
            currentRecord.Data = stream.ToArray();
            currentRecord.Size = (UInt16)currentRecord.Data.Length;
        }
Beispiel #2
0
        public override void Encode()
        {
            MemoryStream memoryStream = new MemoryStream();
            BinaryWriter binaryWriter = new BinaryWriter(memoryStream);

            this.NumStrings = this.StringList.Count;
            binaryWriter.Write(this.TotalOccurance);
            binaryWriter.Write(this.NumStrings);
            this.ContinuedRecords.Clear();
            Record record = this;

            checked
            {
                foreach (string text in this.StringList)
                {
                    int stringDataLength = Record.GetStringDataLength(text);
                    if (memoryStream.Length + unchecked ((long)stringDataLength) > 8224L)
                    {
                        record.Data  = memoryStream.ToArray();
                        record.Size  = (ushort)record.Data.Length;
                        memoryStream = new MemoryStream();
                        binaryWriter = new BinaryWriter(memoryStream);
                        CONTINUE cONTINUE = new CONTINUE();
                        this.ContinuedRecords.Add(cONTINUE);
                        record = cONTINUE;
                    }
                    Record.WriteString(binaryWriter, text, 16);
                }
                record.Data = memoryStream.ToArray();
                record.Size = (ushort)record.Data.Length;
            }
        }
Beispiel #3
0
        private static EXTSST CreateEXTSST(SST sst, int sstOffset)
        {
            EXTSST eXTSST = new EXTSST();

            eXTSST.NumStrings = 8;
            int num = 0;

            checked
            {
                int num2 = sstOffset + 12;
                int num3 = 12;
                foreach (string text in sst.StringList)
                {
                    int stringDataLength = Record.GetStringDataLength(text);
                    if (num3 + stringDataLength > 8228)
                    {
                        num2 += 4;
                        num3  = 4;
                    }
                    if (num == 0)
                    {
                        StringOffset stringOffset = new StringOffset();
                        stringOffset.AbsolutePosition = (uint)num2;
                        stringOffset.RelativePosition = (ushort)num3;
                        eXTSST.Offsets.Add(stringOffset);
                    }
                    num++;
                    if (num == (int)eXTSST.NumStrings)
                    {
                        num = 0;
                    }
                    num2 += stringDataLength;
                    num3 += stringDataLength;
                }
                return(eXTSST);
            }
        }
Beispiel #4
0
        private static EXTSST CreateEXTSST(SST sst, int sstOffset)
        {
            EXTSST extSST = new EXTSST();

            extSST.NumStrings = 8;

            int counter        = 0;
            int totalLength    = sstOffset + 0x0C;
            int relativeLength = 0x0C;

            foreach (string text in sst.StringList)
            {
                int stringLength = Record.GetStringDataLength(text);
                if (relativeLength + stringLength > Record.MaxContentLength + 4)
                {
                    totalLength   += 4;
                    relativeLength = 4;
                }
                if (counter == 0)
                {
                    StringOffset stringOffset = new StringOffset();
                    stringOffset.AbsolutePosition = (uint)totalLength;
                    stringOffset.RelativePosition = (ushort)relativeLength;
                    extSST.Offsets.Add(stringOffset);
                }
                counter++;
                if (counter == extSST.NumStrings)
                {
                    counter = 0;
                }
                totalLength    += stringLength;
                relativeLength += stringLength;
            }

            return(extSST);
        }