Exemplo n.º 1
0
        public void SerializesPickeDocString()
        {
            var pickleDocSring = new PickleDocString
            {
                Location = new Location
                {
                    Line   = 10,
                    Column = 20
                },
                ContentType = "text/plain",
                Content     = "some\ncontent\n"
            };

            byte[] serializedBytes;
            using (MemoryStream stream = new MemoryStream())
            {
                var codedOutputStream = new Google.Protobuf.CodedOutputStream(stream);
                codedOutputStream.WriteMessage(pickleDocSring);
                codedOutputStream.Flush();
                serializedBytes = stream.ToArray();
            }

            PickleDocString parsedCopy = PickleDocString.Parser.ParseDelimitedFrom(new MemoryStream(serializedBytes));

            Assert.Equal(pickleDocSring, parsedCopy);
        }
Exemplo n.º 2
0
        public static byte[] SerializeProtoBuf3 <T>(T data) where T : Google.Protobuf.IMessage
        {
            using (MemoryStream rawOutput = new MemoryStream())
            {
                Google.Protobuf.CodedOutputStream output = new Google.Protobuf.CodedOutputStream(rawOutput);
                //output.WriteRawVarint32((uint)len);
                output.WriteMessage(data);
                output.Flush();
                byte[] result = rawOutput.ToArray();

                return(result);
            }
        }
Exemplo n.º 3
0
        static StackObject *WriteMessage_9(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            Google.Protobuf.IMessage @value = (Google.Protobuf.IMessage) typeof(Google.Protobuf.IMessage).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            Google.Protobuf.CodedOutputStream instance_of_this_method = (Google.Protobuf.CodedOutputStream) typeof(Google.Protobuf.CodedOutputStream).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.WriteMessage(@value);

            return(__ret);
        }