public static EchoRequest DeserializeLengthDelimited(Stream stream, EchoRequest instance)
        {
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            return(EchoRequest.Deserialize(stream, instance, position));
        }
        public static EchoRequest DeserializeLengthDelimited(Stream stream)
        {
            EchoRequest echoRequest = new EchoRequest();

            EchoRequest.DeserializeLengthDelimited(stream, echoRequest);
            return(echoRequest);
        }
Ejemplo n.º 3
0
        public static EchoRequest DeserializeLengthDelimited(Stream stream, EchoRequest instance)
        {
            long num = (long)((ulong)ProtocolParser.ReadUInt32(stream));

            num += stream.get_Position();
            return(EchoRequest.Deserialize(stream, instance, num));
        }
Ejemplo n.º 4
0
        public static EchoRequest Deserialize(Stream stream, EchoRequest instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            instance.NetworkOnly = false;
            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 != 16)
                        {
                            if (num2 != 26)
                            {
                                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.NetworkOnly = ProtocolParser.ReadBool(stream);
                        }
                    }
                    else
                    {
                        instance.Time = binaryReader.ReadUInt64();
                    }
                }
            }
            if (stream.get_Position() == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
        public static EchoRequest Deserialize(Stream stream, EchoRequest instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            instance.NetworkOnly = false;
            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 == 16)
                    {
                        instance.NetworkOnly = ProtocolParser.ReadBool(stream);
                    }
                    else if (num == 26)
                    {
                        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);
        }
        public static void Serialize(Stream stream, EchoRequest instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.HasTime)
            {
                stream.WriteByte(9);
                binaryWriter.Write(instance.Time);
            }
            if (instance.HasNetworkOnly)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteBool(stream, instance.NetworkOnly);
            }
            if (instance.HasPayload)
            {
                stream.WriteByte(26);
                ProtocolParser.WriteBytes(stream, instance.Payload);
            }
        }
        public override bool Equals(object obj)
        {
            EchoRequest echoRequest = obj as EchoRequest;

            if (echoRequest == null)
            {
                return(false);
            }
            if (this.HasTime != echoRequest.HasTime || this.HasTime && !this.Time.Equals(echoRequest.Time))
            {
                return(false);
            }
            if (this.HasNetworkOnly != echoRequest.HasNetworkOnly || this.HasNetworkOnly && !this.NetworkOnly.Equals(echoRequest.NetworkOnly))
            {
                return(false);
            }
            if (this.HasPayload == echoRequest.HasPayload && (!this.HasPayload || this.Payload.Equals(echoRequest.Payload)))
            {
                return(true);
            }
            return(false);
        }
 public static EchoRequest Deserialize(Stream stream, EchoRequest instance)
 {
     return(EchoRequest.Deserialize(stream, instance, (long)-1));
 }
 public void Deserialize(Stream stream)
 {
     EchoRequest.Deserialize(stream, this);
 }
Ejemplo n.º 10
0
        public override bool Equals(object obj)
        {
            EchoRequest echoRequest = obj as EchoRequest;

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