コード例 #1
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;
 }
コード例 #2
0
ファイル: ObjRecord.cs プロジェクト: Johnnyfly/source20131023
        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;
        }