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

            if (instance.CreationAttributes.Count > 0)
            {
                foreach (bnet.protocol.attribute.Attribute attribute in instance.CreationAttributes)
                {
                    stream.WriteByte(10);
                    ProtocolParser.WriteUInt32(stream, attribute.GetSerializedSize());
                    bnet.protocol.attribute.Attribute.Serialize(stream, attribute);
                }
            }
            if (instance.HasFilter)
            {
                stream.WriteByte(18);
                ProtocolParser.WriteUInt32(stream, instance.Filter.GetSerializedSize());
                AttributeFilter.Serialize(stream, instance.Filter);
            }
            if (instance.HasCreate)
            {
                stream.WriteByte(24);
                ProtocolParser.WriteBool(stream, instance.Create);
            }
            if (instance.HasOpen)
            {
                stream.WriteByte(32);
                ProtocolParser.WriteBool(stream, instance.Open);
            }
            if (instance.HasProgramId)
            {
                stream.WriteByte(45);
                binaryWriter.Write(instance.ProgramId);
            }
        }
Example #2
0
        public static void Serialize(Stream stream, GetGameStatsRequest instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            stream.WriteByte(9);
            binaryWriter.Write(instance.FactoryId);
            if (instance.Filter == null)
            {
                throw new ArgumentNullException("Filter", "Required by proto specification.");
            }
            stream.WriteByte(18);
            ProtocolParser.WriteUInt32(stream, instance.Filter.GetSerializedSize());
            AttributeFilter.Serialize(stream, instance.Filter);
        }
        public static void Serialize(Stream stream, FindChannelOptions instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.HasStartIndex)
            {
                stream.WriteByte(8);
                ProtocolParser.WriteUInt32(stream, instance.StartIndex);
            }
            if (instance.HasMaxResults)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt32(stream, instance.MaxResults);
            }
            if (instance.HasName)
            {
                stream.WriteByte(26);
                ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Name));
            }
            if (instance.HasProgram)
            {
                stream.WriteByte(37);
                binaryWriter.Write(instance.Program);
            }
            if (instance.HasLocale)
            {
                stream.WriteByte(45);
                binaryWriter.Write(instance.Locale);
            }
            if (instance.HasCapacityFull)
            {
                stream.WriteByte(48);
                ProtocolParser.WriteUInt32(stream, instance.CapacityFull);
            }
            if (instance.AttributeFilter == null)
            {
                throw new ArgumentNullException("AttributeFilter", "Required by proto specification.");
            }
            stream.WriteByte(58);
            ProtocolParser.WriteUInt32(stream, instance.AttributeFilter.GetSerializedSize());
            AttributeFilter.Serialize(stream, instance.AttributeFilter);
            if (instance.HasChannelType)
            {
                stream.WriteByte(66);
                ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.ChannelType));
            }
        }
Example #4
0
 public static void Serialize(Stream stream, ListFactoriesRequest instance)
 {
     if (instance.Filter == null)
     {
         throw new ArgumentNullException("Filter", "Required by proto specification.");
     }
     stream.WriteByte(10);
     ProtocolParser.WriteUInt32(stream, instance.Filter.GetSerializedSize());
     AttributeFilter.Serialize(stream, instance.Filter);
     if (instance.HasStartIndex)
     {
         stream.WriteByte(16);
         ProtocolParser.WriteUInt32(stream, instance.StartIndex);
     }
     if (instance.HasMaxResults)
     {
         stream.WriteByte(24);
         ProtocolParser.WriteUInt32(stream, instance.MaxResults);
     }
 }
        public static void Serialize(Stream stream, GameProperties instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.CreationAttributes.get_Count() > 0)
            {
                using (List <Attribute> .Enumerator enumerator = instance.CreationAttributes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Attribute current = enumerator.get_Current();
                        stream.WriteByte(10);
                        ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                        Attribute.Serialize(stream, current);
                    }
                }
            }
            if (instance.HasFilter)
            {
                stream.WriteByte(18);
                ProtocolParser.WriteUInt32(stream, instance.Filter.GetSerializedSize());
                AttributeFilter.Serialize(stream, instance.Filter);
            }
            if (instance.HasCreate)
            {
                stream.WriteByte(24);
                ProtocolParser.WriteBool(stream, instance.Create);
            }
            if (instance.HasOpen)
            {
                stream.WriteByte(32);
                ProtocolParser.WriteBool(stream, instance.Open);
            }
            if (instance.HasProgramId)
            {
                stream.WriteByte(45);
                binaryWriter.Write(instance.ProgramId);
            }
        }