Google.Protobuf.MethodDescriptorProto.Serialize C# (CSharp) Method

Serialize() public static method

Serialize the instance into the stream
public static Serialize ( Stream stream, MethodDescriptorProto instance ) : void
stream Stream
instance MethodDescriptorProto
return void
        public static void Serialize(Stream stream, MethodDescriptorProto instance)
        {
            var msField = global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Pop();
            if (instance.Name != null)
            {
                // Key for field: 1, LengthDelimited
                stream.WriteByte(10);
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Name));
            }
            if (instance.InputType != null)
            {
                // Key for field: 2, LengthDelimited
                stream.WriteByte(18);
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.InputType));
            }
            if (instance.OutputType != null)
            {
                // Key for field: 3, LengthDelimited
                stream.WriteByte(26);
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.OutputType));
            }
            if (instance.Options != null)
            {
                // Key for field: 4, LengthDelimited
                stream.WriteByte(34);
                msField.SetLength(0);
                Google.Protobuf.MethodOptions.Serialize(msField, instance.Options);
                // Length delimited byte array
                uint length4 = (uint)msField.Length;
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length4);
                msField.WriteTo(stream);

            }
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField);
        }