public static ArcadeMachine.ScoreEntry Deserialize(Stream stream, ArcadeMachine.ScoreEntry instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num == 8)
         {
             instance.playerID = ProtocolParser.ReadUInt64(stream);
         }
         else if (num == 18)
         {
             instance.displayName = ProtocolParser.ReadString(stream);
         }
         else if (num == 24)
         {
             instance.score = (int)ProtocolParser.ReadUInt64(stream);
         }
         else
         {
             Key key = ProtocolParser.ReadKey((byte)num, stream);
             if (key.Field == 0)
             {
                 throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
             }
             ProtocolParser.SkipKey(stream, key);
         }
     }
     return(instance);
 }
        public static void Serialize(Stream stream, ArcadeMachine instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.scores != null)
            {
                for (int i = 0; i < instance.scores.Count; i++)
                {
                    ArcadeMachine.ScoreEntry item = instance.scores[i];
                    stream.WriteByte(10);
                    memoryStream.SetLength((long)0);
                    ArcadeMachine.ScoreEntry.Serialize(memoryStream, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            stream.WriteByte(16);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.genericInt1);
            stream.WriteByte(24);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.genericInt2);
            stream.WriteByte(32);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.genericInt3);
            stream.WriteByte(40);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.genericInt4);
            stream.WriteByte(53);
            ProtocolParser.WriteSingle(stream, instance.genericFloat1);
            stream.WriteByte(61);
            ProtocolParser.WriteSingle(stream, instance.genericFloat2);
            stream.WriteByte(69);
            ProtocolParser.WriteSingle(stream, instance.genericFloat3);
            stream.WriteByte(77);
            ProtocolParser.WriteSingle(stream, instance.genericFloat4);
            Pool.FreeMemoryStream(ref memoryStream);
        }
 public static ArcadeMachine.ScoreEntry Deserialize(byte[] buffer, ArcadeMachine.ScoreEntry instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         ArcadeMachine.ScoreEntry.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
 public virtual void WriteToStreamDelta(Stream stream, ArcadeMachine.ScoreEntry previous)
 {
     if (previous == null)
     {
         ArcadeMachine.ScoreEntry.Serialize(stream, this);
         return;
     }
     ArcadeMachine.ScoreEntry.SerializeDelta(stream, this, previous);
 }
 public static ArcadeMachine.ScoreEntry Deserialize(byte[] buffer)
 {
     ArcadeMachine.ScoreEntry scoreEntry = Pool.Get <ArcadeMachine.ScoreEntry>();
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         ArcadeMachine.ScoreEntry.Deserialize(memoryStream, scoreEntry, false);
     }
     return(scoreEntry);
 }
 public static byte[] SerializeToBytes(ArcadeMachine.ScoreEntry instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         ArcadeMachine.ScoreEntry.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
 public static void ResetToPool(ArcadeMachine.ScoreEntry instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.playerID    = (ulong)0;
     instance.displayName = string.Empty;
     instance.score       = 0;
     Pool.Free <ArcadeMachine.ScoreEntry>(ref instance);
 }
            public static void Serialize(Stream stream, ArcadeMachine.ScoreEntry instance)
            {
                MemoryStream memoryStream = Pool.Get <MemoryStream>();

                stream.WriteByte(8);
                ProtocolParser.WriteUInt64(stream, instance.playerID);
                if (instance.displayName != null)
                {
                    stream.WriteByte(18);
                    ProtocolParser.WriteString(stream, instance.displayName);
                }
                stream.WriteByte(24);
                ProtocolParser.WriteUInt64(stream, (ulong)instance.score);
                Pool.FreeMemoryStream(ref memoryStream);
            }
 public static void SerializeLengthDelimited(Stream stream, ArcadeMachine.ScoreEntry instance)
 {
     byte[] bytes = ArcadeMachine.ScoreEntry.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
            public static ArcadeMachine.ScoreEntry DeserializeLengthDelimited(Stream stream, ArcadeMachine.ScoreEntry instance, bool isDelta)
            {
                long position = (long)ProtocolParser.ReadUInt32(stream);

                position += stream.Position;
                while (stream.Position < position)
                {
                    int num = stream.ReadByte();
                    if (num == -1)
                    {
                        throw new EndOfStreamException();
                    }
                    if (num == 8)
                    {
                        instance.playerID = ProtocolParser.ReadUInt64(stream);
                    }
                    else if (num == 18)
                    {
                        instance.displayName = ProtocolParser.ReadString(stream);
                    }
                    else if (num == 24)
                    {
                        instance.score = (int)ProtocolParser.ReadUInt64(stream);
                    }
                    else
                    {
                        Key key = ProtocolParser.ReadKey((byte)num, stream);
                        if (key.Field == 0)
                        {
                            throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                        }
                        ProtocolParser.SkipKey(stream, key);
                    }
                }
                if (stream.Position != position)
                {
                    throw new ProtocolBufferException("Read past max limit");
                }
                return(instance);
            }
 public static ArcadeMachine.ScoreEntry DeserializeLengthDelimited(Stream stream)
 {
     ArcadeMachine.ScoreEntry scoreEntry = Pool.Get <ArcadeMachine.ScoreEntry>();
     ArcadeMachine.ScoreEntry.DeserializeLengthDelimited(stream, scoreEntry, false);
     return(scoreEntry);
 }
 public static ArcadeMachine.ScoreEntry DeserializeLength(Stream stream, int length)
 {
     ArcadeMachine.ScoreEntry scoreEntry = Pool.Get <ArcadeMachine.ScoreEntry>();
     ArcadeMachine.ScoreEntry.DeserializeLength(stream, length, scoreEntry, false);
     return(scoreEntry);
 }
 public void CopyTo(ArcadeMachine.ScoreEntry instance)
 {
     instance.playerID    = this.playerID;
     instance.displayName = this.displayName;
     instance.score       = this.score;
 }
 public ArcadeMachine.ScoreEntry Copy()
 {
     ArcadeMachine.ScoreEntry scoreEntry = Pool.Get <ArcadeMachine.ScoreEntry>();
     this.CopyTo(scoreEntry);
     return(scoreEntry);
 }