public static ILightData ParseData(LightBuffer lightBuffer) { ILightData data = null; LightDataType dataType = lightBuffer.ReadDataType(); switch (dataType) { case LightDataType.Object: byte[] tempBuffer = new byte[lightBuffer.buffer.Length - lightBuffer.offset]; Buffer.BlockCopy(lightBuffer.buffer, lightBuffer.offset, tempBuffer, 0, tempBuffer.Length); LightBuffer objectBuffer = new LightBuffer(tempBuffer); LightObject tempObj = new LightObject(); tempObj.key = objectBuffer.ReadByte(); int dataCount = objectBuffer.ReadByte(); for (int i = 0; i < dataCount; i++) { tempObj.AddLightData(ParseData(objectBuffer)); } data = tempObj; lightBuffer.offset += objectBuffer.offset; break; case LightDataType.Int: data = LightInt.Deserialize(lightBuffer); break; } return(data); }
public void PutObject(byte key, LightObject obj) { obj.key = key; AddLightData(obj); }