Google.Protobuf.CodedOutputStream.WriteRawBytes C# (CSharp) Method

WriteRawBytes() private method

Writes out an array of bytes.
private WriteRawBytes ( byte value ) : void
value byte
return void
        internal void WriteRawBytes(byte[] value)
        {
            WriteRawBytes(value, 0, value.Length);
        }

Same methods

CodedOutputStream::WriteRawBytes ( byte value, int offset, int length ) : void

Usage Example

Example #1
0
        public void ReadStringGreaterThanCurrentLimit()
        {
            MemoryStream      ms     = new MemoryStream();
            CodedOutputStream output = new CodedOutputStream(ms);
            uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);

            output.WriteRawVarint32(tag);
            output.WriteRawVarint32(4);
            output.WriteRawBytes(new byte[4]); // Pad with a few random bytes.
            output.Flush();
            ms.Position = 0;

            CodedInputStream input = new CodedInputStream(ms.ToArray());

            Assert.AreEqual(tag, input.ReadTag());

            // Specify limit smaller than data length
            input.PushLimit(3);
            Assert.Throws <InvalidProtocolBufferException>(() => input.ReadString());

            AssertReadFromParseContext(new ReadOnlySequence <byte>(ms.ToArray()), (ref ParseContext ctx) =>
            {
                Assert.AreEqual(tag, ctx.ReadTag());
                SegmentedBufferHelper.PushLimit(ref ctx.state, 3);
                try
                {
                    ctx.ReadString();
                    Assert.Fail();
                }
                catch (InvalidProtocolBufferException) { }
            }, true);
        }
All Usage Examples Of Google.Protobuf.CodedOutputStream::WriteRawBytes