public DataStructure TightUnmarshalNestedObject(BinaryReader dis, BooleanStream bs)
        {
            if (bs.ReadBoolean())
            {
                byte dataType = dis.ReadByte();
                BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller)dataMarshallers[dataType & 0xFF];
                if (dsm == null)
                {
                    throw new IOException("Unknown data type: " + dataType);
                }
                DataStructure data = dsm.CreateObject();

                if (data.IsMarshallAware() && bs.ReadBoolean())
                {
                    dis.ReadInt32();
                    dis.ReadByte();

                    BooleanStream bs2 = new BooleanStream();
                    bs2.Unmarshal(dis);
                    dsm.TightUnmarshal(this, data, dis, bs2);

                    // TODO: extract the sequence from the dis and associate it.
                    //                MarshallAware ma = (MarshallAware)data
                    //                ma.setCachedMarshalledForm(this, sequence);
                }
                else
                {
                    dsm.TightUnmarshal(this, data, dis, bs);
                }

                return(data);
            }
            else
            {
                return(null);
            }
        }
        public Object Unmarshal(BinaryReader dis)
        {
            // lets ignore the size of the packet
            if (!sizePrefixDisabled)
            {
                dis.ReadInt32();
            }

            // first byte is the type of the packet
            byte dataType = dis.ReadByte();

            if (dataType != NULL_TYPE)
            {
                BaseDataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF];
                if (dsm == null)
                {
                    throw new IOException("Unknown data type: " + dataType);
                }
                //Console.WriteLine("Parsing type: " + dataType + " with: " + dsm);
                Object data = dsm.CreateObject();

                if (tightEncodingEnabled)
                {
                    BooleanStream bs = new BooleanStream();
                    bs.Unmarshal(dis);
                    dsm.TightUnmarshal(this, data, dis, bs);
                    return(data);
                }
                else
                {
                    dsm.LooseUnmarshal(this, data, dis);
                    return(data);
                }
            }
            else
            {
                return(null);
            }
        }