public static void Serialize(Stream stream, ServerInfo instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.Host == null)
            {
                throw new ArgumentNullException("Host", "Required by proto specification.");
            }
            stream.WriteByte(10);
            ProtocolParser.WriteUInt32(stream, instance.Host.GetSerializedSize());
            ProcessId.Serialize(stream, instance.Host);
            if (instance.HasReplace)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteBool(stream, instance.Replace);
            }
            if (instance.HasState)
            {
                stream.WriteByte(26);
                ProtocolParser.WriteUInt32(stream, instance.State.GetSerializedSize());
                ServerState.Serialize(stream, instance.State);
            }
            if (instance.Attribute.get_Count() > 0)
            {
                using (List <Attribute> .Enumerator enumerator = instance.Attribute.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Attribute current = enumerator.get_Current();
                        stream.WriteByte(34);
                        ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                        bnet.protocol.attribute.Attribute.Serialize(stream, current);
                    }
                }
            }
            if (instance.HasProgramId)
            {
                stream.WriteByte(45);
                binaryWriter.Write(instance.ProgramId);
            }
        }
Exemplo n.º 2
0
        public static void Serialize(Stream stream, ServerInfo instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.Host == null)
            {
                throw new ArgumentNullException("Host", "Required by proto specification.");
            }
            stream.WriteByte(10);
            ProtocolParser.WriteUInt32(stream, instance.Host.GetSerializedSize());
            ProcessId.Serialize(stream, instance.Host);
            if (instance.HasReplace)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteBool(stream, instance.Replace);
            }
            if (instance.HasState)
            {
                stream.WriteByte(26);
                ProtocolParser.WriteUInt32(stream, instance.State.GetSerializedSize());
                ServerState.Serialize(stream, instance.State);
            }
            if (instance.Attribute.Count > 0)
            {
                foreach (bnet.protocol.attribute.Attribute attribute in instance.Attribute)
                {
                    stream.WriteByte(34);
                    ProtocolParser.WriteUInt32(stream, attribute.GetSerializedSize());
                    bnet.protocol.attribute.Attribute.Serialize(stream, attribute);
                }
            }
            if (instance.HasProgramId)
            {
                stream.WriteByte(45);
                binaryWriter.Write(instance.ProgramId);
            }
        }
Exemplo n.º 3
0
 public void Serialize(Stream stream)
 {
     ServerState.Serialize(stream, this);
 }