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

Serialize() public static method

Serialize the instance into the stream
public static Serialize ( Stream stream, ServiceDescriptorProto instance ) : void
stream Stream
instance ServiceDescriptorProto
return void
        public static void Serialize(Stream stream, ServiceDescriptorProto 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.Method != null)
            {
                foreach (var i2 in instance.Method)
                {
                    // Key for field: 2, LengthDelimited
                    stream.WriteByte(18);
                    msField.SetLength(0);
                    Google.Protobuf.MethodDescriptorProto.Serialize(msField, i2);
                    // Length delimited byte array
                    uint length2 = (uint)msField.Length;
                    global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length2);
                    msField.WriteTo(stream);

                }
            }
            if (instance.Options != null)
            {
                // Key for field: 3, LengthDelimited
                stream.WriteByte(26);
                msField.SetLength(0);
                Google.Protobuf.ServiceOptions.Serialize(msField, instance.Options);
                // Length delimited byte array
                uint length3 = (uint)msField.Length;
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length3);
                msField.WriteTo(stream);

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