public static ServerRequest DeserializeLengthDelimited(Stream stream, ServerRequest instance)
        {
            long num = (long)((ulong)ProtocolParser.ReadUInt32(stream));

            num += stream.get_Position();
            return(ServerRequest.Deserialize(stream, instance, num));
        }
        public static void Serialize(Stream stream, ServerRequest instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.Attribute.get_Count() > 0)
            {
                using (List <Attribute> .Enumerator enumerator = instance.Attribute.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Attribute current = enumerator.get_Current();
                        stream.WriteByte(10);
                        ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                        bnet.protocol.attribute.Attribute.Serialize(stream, current);
                    }
                }
            }
            stream.WriteByte(21);
            binaryWriter.Write(instance.Program);
            if (instance.HasHost)
            {
                stream.WriteByte(26);
                ProtocolParser.WriteUInt32(stream, instance.Host.GetSerializedSize());
                ProcessId.Serialize(stream, instance.Host);
            }
        }
        public static ServerRequest DeserializeLengthDelimited(Stream stream)
        {
            ServerRequest serverRequest = new ServerRequest();

            ServerRequest.DeserializeLengthDelimited(stream, serverRequest);
            return(serverRequest);
        }
Example #4
0
        public override bool Equals(object obj)
        {
            ServerRequest serverRequest = obj as ServerRequest;

            if (serverRequest == null)
            {
                return(false);
            }
            if (this.Attribute.Count != serverRequest.Attribute.Count)
            {
                return(false);
            }
            for (int i = 0; i < this.Attribute.Count; i++)
            {
                if (!this.Attribute[i].Equals(serverRequest.Attribute[i]))
                {
                    return(false);
                }
            }
            if (!this.Program.Equals(serverRequest.Program))
            {
                return(false);
            }
            if (this.HasHost == serverRequest.HasHost && (!this.HasHost || this.Host.Equals(serverRequest.Host)))
            {
                return(true);
            }
            return(false);
        }
Example #5
0
        public static ServerRequest DeserializeLengthDelimited(Stream stream, ServerRequest instance)
        {
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            return(ServerRequest.Deserialize(stream, instance, position));
        }
Example #6
0
        public static ServerRequest Deserialize(Stream stream, ServerRequest instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            if (instance.Attribute == null)
            {
                instance.Attribute = new List <bnet.protocol.attribute.Attribute>();
            }
            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 == 10)
                    {
                        instance.Attribute.Add(bnet.protocol.attribute.Attribute.DeserializeLengthDelimited(stream));
                    }
                    else if (num == 21)
                    {
                        instance.Program = binaryReader.ReadUInt32();
                    }
                    else if (num != 26)
                    {
                        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 (instance.Host != null)
                    {
                        ProcessId.DeserializeLengthDelimited(stream, instance.Host);
                    }
                    else
                    {
                        instance.Host = ProcessId.DeserializeLengthDelimited(stream);
                    }
                }
                else
                {
                    if (stream.Position != limit)
                    {
                        throw new ProtocolBufferException("Read past max limit");
                    }
                    break;
                }
            }
            return(instance);
        }
        public override bool Equals(object obj)
        {
            ServerRequest serverRequest = obj as ServerRequest;

            if (serverRequest == null)
            {
                return(false);
            }
            if (this.Attribute.get_Count() != serverRequest.Attribute.get_Count())
            {
                return(false);
            }
            for (int i = 0; i < this.Attribute.get_Count(); i++)
            {
                if (!this.Attribute.get_Item(i).Equals(serverRequest.Attribute.get_Item(i)))
                {
                    return(false);
                }
            }
            return(this.Program.Equals(serverRequest.Program) && this.HasHost == serverRequest.HasHost && (!this.HasHost || this.Host.Equals(serverRequest.Host)));
        }
Example #8
0
        public static void Serialize(Stream stream, ServerRequest instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.Attribute.Count > 0)
            {
                foreach (bnet.protocol.attribute.Attribute attribute in instance.Attribute)
                {
                    stream.WriteByte(10);
                    ProtocolParser.WriteUInt32(stream, attribute.GetSerializedSize());
                    bnet.protocol.attribute.Attribute.Serialize(stream, attribute);
                }
            }
            stream.WriteByte(21);
            binaryWriter.Write(instance.Program);
            if (instance.HasHost)
            {
                stream.WriteByte(26);
                ProtocolParser.WriteUInt32(stream, instance.Host.GetSerializedSize());
                ProcessId.Serialize(stream, instance.Host);
            }
        }
 public static ServerRequest Deserialize(Stream stream, ServerRequest instance)
 {
     return(ServerRequest.Deserialize(stream, instance, -1L));
 }
 public void Deserialize(Stream stream)
 {
     ServerRequest.Deserialize(stream, this);
 }