Exemple #1
0
        public static void MergeDelimitedFrom(this IMessage message, Stream input)
        {
            Preconditions.CheckNotNull <IMessage>(message, Module.smethod_33 <string>(879293356u));
            Preconditions.CheckNotNull <Stream>(input, Module.smethod_36 <string>(1587331305u));
            int size;

            while (true)
            {
IL_55:
                uint arg_3D_0 = 1352182406u;
                while (true)
                {
                    uint num;
                    switch ((num = (arg_3D_0 ^ 864799055u)) % 3u)
                    {
                    case 0u:
                        goto IL_55;

                    case 1u:
                        size     = (int)CodedInputStream.ReadRawVarint32(input);
                        arg_3D_0 = (num * 2731188668u ^ 3872850211u);
                        continue;
                    }
                    goto Block_1;
                }
            }
Block_1:
            Stream input2 = new LimitedInputStream(input, size);

            message.MergeFrom(input2);
        }
 public static void MergeDelimitedFrom(this IMessage message, Stream input)
 {
     Preconditions.CheckNotNull(message, "message");
     Preconditions.CheckNotNull(input, "input");
     int size = (int) CodedInputStream.ReadRawVarint32(input);
     Stream limitedStream = new LimitedInputStream(input, size);
     message.MergeFrom(limitedStream);
 }
Exemple #3
0
        internal static void MergeDelimitedFrom(this IMessage message, Stream input, bool discardUnknownFields, ExtensionRegistry registry)
        {
            ProtoPreconditions.CheckNotNull(message, "message");
            ProtoPreconditions.CheckNotNull(input, "input");
            int    size          = (int)CodedInputStream.ReadRawVarint32(input);
            Stream limitedStream = new LimitedInputStream(input, size);

            MergeFrom(message, limitedStream, discardUnknownFields, registry);
        }
Exemple #4
0
        /// <summary>
        /// Merges length-delimited data from the given stream into an existing message.
        /// </summary>
        /// <remarks>
        /// The stream is expected to contain a length and then the data. Only the amount of data
        /// specified by the length will be consumed.
        /// </remarks>
        /// <param name="message">The message to merge the data into.</param>
        /// <param name="input">Stream containing the data to merge, which must be protobuf-encoded binary data.</param>
        public static void MergeDelimitedFrom(this IMessage message, Stream input)
        {
            ProtoPreconditions.CheckNotNull(message, "message");
            ProtoPreconditions.CheckNotNull(input, "input");
            int    size          = (int)CodedInputStream.ReadRawVarint32(input);
            Stream limitedStream = new LimitedInputStream(input, size);

            message.MergeFrom(limitedStream);
        }
Exemple #5
0
        public void FromStream_NotSeekable()
        {
            var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 });

            // Consume the first byte, just to test that it's "from current position"
            stream.ReadByte();
            // Wrap the original stream in LimitedInputStream, which has CanSeek=false
            var        limitedStream = new LimitedInputStream(stream, 3);
            var        actual        = ByteString.FromStream(limitedStream);
            ByteString expected      = ByteString.CopyFrom(2, 3, 4);

            Assert.AreEqual(expected, actual, $"{expected.ToBase64()} != {actual.ToBase64()}");
        }
        public override int Read(byte[] buffer, int offset, int count)
        {
            if (this.bytesLeft > 0)
            {
                while (true)
                {
IL_61:
                    uint arg_45_0 = 1171296126u;
                    while (true)
                    {
                        uint num;
                        switch ((num = (arg_45_0 ^ 370393729u)) % 4u)
                        {
                        case 0u:
                            goto IL_61;

                        case 2u:
                        {
                            int num2;
                            return(num2);
                        }

                        case 3u:
                        {
                            int num2 = LimitedInputStream.smethod_2(this.proxied, buffer, offset, LimitedInputStream.smethod_1(this.bytesLeft, count));
                            this.bytesLeft -= num2;
                            arg_45_0        = (num * 134526951u ^ 422163270u);
                            continue;
                        }
                        }
                        goto Block_2;
                    }
                }
Block_2:
                return(0);
            }
            return(0);
        }
 public override void Write(byte[] buffer, int offset, int count)
 {
     throw LimitedInputStream.smethod_0();
 }
 public override void SetLength(long value)
 {
     throw LimitedInputStream.smethod_0();
 }
 public override long Seek(long offset, SeekOrigin origin)
 {
     throw LimitedInputStream.smethod_0();
 }