WriteMessage() 공개 메소드

Writes a message, without a tag, to the stream. The data is length-prefixed.
public WriteMessage ( IMessage value ) : void
value IMessage The value to write
리턴 void
예제 #1
0
     public void WriteTo(pb.CodedOutputStream output)
     {
 #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
         output.WriteRawMessage(this);
 #else
         if (ClientId.Length != 0)
         {
             output.WriteRawTag(10);
             output.WriteString(ClientId);
         }
         if (MessageId.Length != 0)
         {
             output.WriteRawTag(18);
             output.WriteString(MessageId);
         }
         if (Type != MessageType.Undefined)
         {
             output.WriteRawTag(24);
             output.WriteEnum((int)Type);
         }
         if (time_ != null)
         {
             output.WriteRawTag(34);
             output.WriteMessage(Time);
         }
         if (Status != MessageStatus.Undefined)
         {
             output.WriteRawTag(40);
             output.WriteEnum((int)Status);
         }
         if (Payload.Length != 0)
         {
             output.WriteRawTag(50);
             output.WriteBytes(Payload);
         }
         if (Response != ResponseType.Undefined)
         {
             output.WriteRawTag(56);
             output.WriteEnum((int)Response);
         }
         if (_unknownFields != null)
         {
             _unknownFields.WriteTo(output);
         }
 #endif
     }
예제 #2
0
        public void MapWithOnlyValue()
        {
            // Hand-craft the stream to contain a single entry with just a value.
            var memoryStream = new MemoryStream();
            var output       = new CodedOutputStream(memoryStream);

            output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited);
            var nestedMessage = new ForeignMessage {
                C = 20
            };

            // Size of the entry (tag, size written by WriteMessage, data written by WriteMessage)
            output.WriteLength(2 + nestedMessage.CalculateSize());
            output.WriteTag(2, WireFormat.WireType.LengthDelimited);
            output.WriteMessage(nestedMessage);
            output.Flush();

            var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());

            Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]);
        }
예제 #3
0
        public void MapWithOnlyValue()
        {
            // Hand-craft the stream to contain a single entry with just a value.
            var memoryStream = new MemoryStream();
            var output = new CodedOutputStream(memoryStream);
            output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited);
            var nestedMessage = new ForeignMessage { C = 20 };
            // Size of the entry (tag, size written by WriteMessage, data written by WriteMessage)
            output.WriteLength(2 + nestedMessage.CalculateSize());
            output.WriteTag(2, WireFormat.WireType.LengthDelimited);
            output.WriteMessage(nestedMessage);
            output.Flush();

            var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
            Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]);
        }
예제 #4
0
 internal void <ForMessage> b__16_1(CodedOutputStream output, T value)
 {
     output.WriteMessage(value);
 }