Пример #1
0
 public static void Serialize(Stream stream, Field instance)
 {
     if (instance.Key == null)
     {
         throw new ArgumentNullException("Key", "Required by proto specification.");
     }
     stream.WriteByte(10);
     ProtocolParser.WriteUInt32(stream, instance.Key.GetSerializedSize());
     FieldKey.Serialize(stream, instance.Key);
     if (instance.Value == null)
     {
         throw new ArgumentNullException("Value", "Required by proto specification.");
     }
     stream.WriteByte(18);
     ProtocolParser.WriteUInt32(stream, instance.Value.GetSerializedSize());
     Variant.Serialize(stream, instance.Value);
 }
 public static void Serialize(Stream stream, QueryRequest instance)
 {
     if (instance.EntityId == null)
     {
         throw new ArgumentNullException("EntityId", "Required by proto specification.");
     }
     stream.WriteByte(10);
     ProtocolParser.WriteUInt32(stream, instance.EntityId.GetSerializedSize());
     bnet.protocol.EntityId.Serialize(stream, instance.EntityId);
     if (instance.Key.Count > 0)
     {
         foreach (FieldKey key in instance.Key)
         {
             stream.WriteByte(18);
             ProtocolParser.WriteUInt32(stream, key.GetSerializedSize());
             FieldKey.Serialize(stream, key);
         }
     }
 }
 public static void Serialize(Stream stream, QueryRequest instance)
 {
     if (instance.EntityId == null)
     {
         throw new ArgumentNullException("EntityId", "Required by proto specification.");
     }
     stream.WriteByte(10);
     ProtocolParser.WriteUInt32(stream, instance.EntityId.GetSerializedSize());
     EntityId.Serialize(stream, instance.EntityId);
     if (instance.Key.get_Count() > 0)
     {
         using (List <FieldKey> .Enumerator enumerator = instance.Key.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 FieldKey current = enumerator.get_Current();
                 stream.WriteByte(18);
                 ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                 FieldKey.Serialize(stream, current);
             }
         }
     }
 }
 public void Serialize(Stream stream)
 {
     FieldKey.Serialize(stream, this);
 }