Exemplo n.º 1
0
 public override int Serialize(int offset, byte[] data)
 {
     ILittleEndianOutput leo = new LittleEndianByteArrayOutputStream(data, offset);
     ContinuableRecordOutput out1 = new ContinuableRecordOutput(leo, this.Sid);
     Serialize(out1);
     out1.Terminate();
     return out1.TotalSize;
 }
Exemplo n.º 2
0
 public override int Serialize(int offset, byte[] data)
 {
     int dataSize = DataSize;
     int recSize = 4 + dataSize;
     LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset, recSize);
     out1.WriteShort(this.Sid);
     out1.WriteShort(dataSize);
     Serialize(out1);
     if (out1.WriteIndex - offset != recSize)
     {
         throw new InvalidOperationException("Error in serialization of (" + this.GetType().Name + "): "
                 + "Incorrect number of bytes written - expected "
                 + recSize + " but got " + (out1.WriteIndex - offset));
     }
     return recSize;
 }
 public ILittleEndianOutput CreateDelayedOutput(int size)
 {
     CheckPosition(size);
     ILittleEndianOutput result = new LittleEndianByteArrayOutputStream(_buf, _writeIndex, size);
     _writeIndex += size;
     return result;
 }
Exemplo n.º 4
0
 public override int Serialize(int offset, byte[] data)
 {
     LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset,this.RecordSize);
     int result=this.Serialize(out1);
     if (out1.WriteIndex - offset != this.RecordSize)
     {
         throw new InvalidOperationException("Error in serialization of (" + this.GetType().Name + "): "
                 + "Incorrect number of bytes written - expected "
                 + this.RecordSize + " but got " + (out1.WriteIndex - offset));
     }
     return result;
 }
Exemplo n.º 5
0
        public override int Serialize(int offset, byte [] data)
        {
            int recSize = RecordSize;
            int dataSize = recSize - 4;

            LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset, recSize);

		    out1.WriteShort(sid);
		    out1.WriteShort(dataSize);

            if (_uninterpretedData == null)
            {
                for (int i = 0; i < subrecords.Count; i++)
                {
                    SubRecord record = subrecords[i];
                    record.Serialize(out1);
                }
                int expectedEndIx = offset + dataSize;
                // padding
                while (out1.WriteIndex < expectedEndIx)
                {
                    out1.WriteByte(0);
                }
            }
            else
            {
                out1.Write(_uninterpretedData);
            }
            return recSize;
        }
Exemplo n.º 6
0
        /**
         * Writes the ptgs to the data buffer, starting at the specified offset.  
         *
         * <br/>
         * The 2 byte encode Length field is <b>not</b> written by this method.
         * @return number of bytes written
         */
        public static int SerializePtgs(Ptg[] ptgs, byte[] array, int offset)
        {
            int size = ptgs.Length;

            LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(array, offset);

            ArrayList arrayPtgs = null;

            for (int k = 0; k < size; k++)
            {
                Ptg ptg = ptgs[k];

                ptg.Write(out1);
                if (ptg is ArrayPtg)
                {
                    if (arrayPtgs == null)
                    {
                        arrayPtgs = new ArrayList(5);
                    }
                    arrayPtgs.Add(ptg);

                }
            }
            if (arrayPtgs != null)
            {
                for (int i = 0; i < arrayPtgs.Count; i++)
                {
                    ArrayPtg p = (ArrayPtg)arrayPtgs[i];
                    p.WriteTokenValueBytes(out1);
                }
            }
            return out1.WriteIndex - offset; ;
        }