Example #1
0
        public static BindRequest Deserialize(Stream stream, BindRequest instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            if (instance.ImportedServiceHash == null)
            {
                instance.ImportedServiceHash = new List <uint>();
            }
            if (instance.ExportedService == null)
            {
                instance.ExportedService = new List <BoundService>();
            }
            while (limit < 0L || stream.Position < limit)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    if (limit >= 0L)
                    {
                        throw new EndOfStreamException();
                    }
                    return(instance);
                }
                else if (num != 10)
                {
                    if (num != 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.ExportedService.Add(BoundService.DeserializeLengthDelimited(stream));
                    }
                }
                else
                {
                    long num2 = (long)((ulong)ProtocolParser.ReadUInt32(stream));
                    num2 += stream.Position;
                    while (stream.Position < num2)
                    {
                        instance.ImportedServiceHash.Add(binaryReader.ReadUInt32());
                    }
                    if (stream.Position != num2)
                    {
                        throw new ProtocolBufferException("Read too many bytes in packed data");
                    }
                }
            }
            if (stream.Position == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
Example #2
0
        public static BoundService DeserializeLengthDelimited(Stream stream)
        {
            BoundService boundService = new BoundService();

            BoundService.DeserializeLengthDelimited(stream, boundService);
            return(boundService);
        }