public Object ReadObject()
{
InitializeReading();
long startingPos = this.byteBuffer.Position;
try
{
int type = this.dataIn.ReadByte();
if(type == PrimitiveMap.BIG_STRING_TYPE)
{
return this.dataIn.ReadString32();
}
else if(type == PrimitiveMap.STRING_TYPE)
{
return this.dataIn.ReadString16();
}
else if(type == PrimitiveMap.LONG_TYPE)
{
return this.dataIn.ReadInt64();
}
else if(type == PrimitiveMap.INTEGER_TYPE)
{
return this.dataIn.ReadInt32();
}
else if(type == PrimitiveMap.SHORT_TYPE)
{
return this.dataIn.ReadInt16();
}
else if(type == PrimitiveMap.FLOAT_TYPE)
{
return this.dataIn.ReadSingle();
}
else if(type == PrimitiveMap.DOUBLE_TYPE)
{
return this.dataIn.ReadDouble();
}
else if(type == PrimitiveMap.CHAR_TYPE)
{
return this.dataIn.ReadChar();
}
else if(type == PrimitiveMap.BYTE_TYPE)
{
return this.dataIn.ReadByte();
}
else if(type == PrimitiveMap.BOOLEAN_TYPE)
{
return this.dataIn.ReadBoolean();
}
else if(type == PrimitiveMap.BYTE_ARRAY_TYPE)
{
int length = this.dataIn.ReadInt32();
byte[] data = new byte[length];
this.dataIn.Read(data, 0, length);
return data;
}
else if(type == PrimitiveMap.NULL)
{
return null;
}
else
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new MessageFormatException("Value is not a known type.");
}
}
catch(FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
catch(EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
catch(IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}