Exemplo n.º 1
0
        internal IProtocol Deserialize_Internal(MyStream stream)
        {
            int oldPos = stream.Position;

            this.CurProtocolId = stream.ReadInt();
            Type targetType     = id2Type[this.CurProtocolId];
            int  protocolLength = stream.ReadInt();
            int  finalPos       = stream.Position + protocolLength;

            if (stream.RemainCount < protocolLength)
            {
                //长度不够,回滚Position
                stream.Position = oldPos;
                return(null);
            }

            IProtocol result = _Deserialize(stream, targetType) as IProtocol;

            if (stream.Position != finalPos)
            {
                throw new LengthException();
                //rs.Position = startPos + protocolLength;
            }
            return(result);
        }
Exemplo n.º 2
0
 internal override object GetDeserializeValue(MyStream stream)
 {
     return(stream.ReadInt());
 }