Esempio n. 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;
        }
Esempio n. 2
0
 public virtual void Encode()
 {
     this.ContinuedRecords.Clear();
     if (Size > 0 && Data.Length > MaxContentLength)
     {
         int index = MaxContentLength;
         while (index < Data.Length)
         {
             CONTINUE continuedRecord = new CONTINUE();
             int      size            = Math.Min(MaxContentLength, Data.Length - index);
             continuedRecord.Data = Algorithm.ArraySection(Data, index, size);
             continuedRecord.Size = (ushort)size;
             this.ContinuedRecords.Add(continuedRecord);
             index += size;
         }
         this.Size = MaxContentLength;
         this.Data = Algorithm.ArraySection(Data, 0, MaxContentLength);
     }
 }