コード例 #1
0
        public static EchoRequest DeserializeLengthDelimited(Stream stream, EchoRequest instance)
        {
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            return(EchoRequest.Deserialize(stream, instance, position));
        }
コード例 #2
0
        public static EchoRequest DeserializeLengthDelimited(Stream stream)
        {
            EchoRequest echoRequest = new EchoRequest();

            EchoRequest.DeserializeLengthDelimited(stream, echoRequest);
            return(echoRequest);
        }
コード例 #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));
        }
コード例 #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");
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 public static EchoRequest Deserialize(Stream stream, EchoRequest instance)
 {
     return(EchoRequest.Deserialize(stream, instance, (long)-1));
 }
コード例 #9
0
 public void Deserialize(Stream stream)
 {
     EchoRequest.Deserialize(stream, this);
 }
コード例 #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)));
        }