public static EchoResponse DeserializeLengthDelimited(Stream stream)
        {
            EchoResponse echoResponse = new EchoResponse();

            EchoResponse.DeserializeLengthDelimited(stream, echoResponse);
            return(echoResponse);
        }
        public static EchoResponse DeserializeLengthDelimited(Stream stream, EchoResponse instance)
        {
            long num = (long)((ulong)ProtocolParser.ReadUInt32(stream));

            num += stream.get_Position();
            return(EchoResponse.Deserialize(stream, instance, num));
        }
示例#3
0
        public static EchoResponse DeserializeLengthDelimited(Stream stream, EchoResponse instance)
        {
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            return(EchoResponse.Deserialize(stream, instance, position));
        }
        public static void Serialize(Stream stream, EchoResponse instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.HasTime)
            {
                stream.WriteByte(9);
                binaryWriter.Write(instance.Time);
            }
            if (instance.HasPayload)
            {
                stream.WriteByte(18);
                ProtocolParser.WriteBytes(stream, instance.Payload);
            }
        }
        public static EchoResponse Deserialize(Stream stream, EchoResponse instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            while (limit < 0L || stream.get_Position() < limit)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    if (limit >= 0L)
                    {
                        throw new EndOfStreamException();
                    }
                    return(instance);
                }
                else
                {
                    int num2 = num;
                    if (num2 != 9)
                    {
                        if (num2 != 18)
                        {
                            Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                            uint field = key.Field;
                            if (field == 0u)
                            {
                                throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                            }
                            ProtocolParser.SkipKey(stream, key);
                        }
                        else
                        {
                            instance.Payload = ProtocolParser.ReadBytes(stream);
                        }
                    }
                    else
                    {
                        instance.Time = binaryReader.ReadUInt64();
                    }
                }
            }
            if (stream.get_Position() == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
示例#6
0
        public static EchoResponse Deserialize(Stream stream, EchoResponse instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            while (true)
            {
                if (limit < (long)0 || stream.Position < limit)
                {
                    int num = stream.ReadByte();
                    if (num == -1)
                    {
                        if (limit >= (long)0)
                        {
                            throw new EndOfStreamException();
                        }
                        break;
                    }
                    else if (num == 9)
                    {
                        instance.Time = binaryReader.ReadUInt64();
                    }
                    else if (num == 18)
                    {
                        instance.Payload = ProtocolParser.ReadBytes(stream);
                    }
                    else
                    {
                        Key key = ProtocolParser.ReadKey((byte)num, stream);
                        if (key.Field == 0)
                        {
                            throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                        }
                        ProtocolParser.SkipKey(stream, key);
                    }
                }
                else
                {
                    if (stream.Position != limit)
                    {
                        throw new ProtocolBufferException("Read past max limit");
                    }
                    break;
                }
            }
            return(instance);
        }
示例#7
0
        public override bool Equals(object obj)
        {
            EchoResponse echoResponse = obj as EchoResponse;

            if (echoResponse == null)
            {
                return(false);
            }
            if (this.HasTime != echoResponse.HasTime || this.HasTime && !this.Time.Equals(echoResponse.Time))
            {
                return(false);
            }
            if (this.HasPayload == echoResponse.HasPayload && (!this.HasPayload || this.Payload.Equals(echoResponse.Payload)))
            {
                return(true);
            }
            return(false);
        }
 public static EchoResponse Deserialize(Stream stream, EchoResponse instance)
 {
     return(EchoResponse.Deserialize(stream, instance, -1L));
 }
 public void Deserialize(Stream stream)
 {
     EchoResponse.Deserialize(stream, this);
 }
        public override bool Equals(object obj)
        {
            EchoResponse echoResponse = obj as EchoResponse;

            return(echoResponse != null && this.HasTime == echoResponse.HasTime && (!this.HasTime || this.Time.Equals(echoResponse.Time)) && this.HasPayload == echoResponse.HasPayload && (!this.HasPayload || this.Payload.Equals(echoResponse.Payload)));
        }