Пример #1
0
        public static ArcadeGame DeserializeLength(Stream stream, int length)
        {
            ArcadeGame arcadeGame = Pool.Get <ArcadeGame>();

            ArcadeGame.DeserializeLength(stream, length, arcadeGame, false);
            return(arcadeGame);
        }
Пример #2
0
        public static ArcadeGame DeserializeLength(Stream stream, int length, ArcadeGame instance, bool isDelta)
        {
            if (!isDelta && instance.arcadeEnts == null)
            {
                instance.arcadeEnts = Pool.Get <List <ArcadeGame.arcadeEnt> >();
            }
            long position = stream.Position + (long)length;

            while (stream.Position < position)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    throw new EndOfStreamException();
                }
                if (num != 10)
                {
                    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);
                }
                else
                {
                    instance.arcadeEnts.Add(ArcadeGame.arcadeEnt.DeserializeLengthDelimited(stream));
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
Пример #3
0
        public ArcadeGame Copy()
        {
            ArcadeGame arcadeGame = Pool.Get <ArcadeGame>();

            this.CopyTo(arcadeGame);
            return(arcadeGame);
        }
Пример #4
0
        public static ArcadeGame Deserialize(Stream stream)
        {
            ArcadeGame arcadeGame = Pool.Get <ArcadeGame>();

            ArcadeGame.Deserialize(stream, arcadeGame, false);
            return(arcadeGame);
        }
Пример #5
0
 public static ArcadeGame Deserialize(Stream stream, ArcadeGame instance, bool isDelta)
 {
     if (!isDelta && instance.arcadeEnts == null)
     {
         instance.arcadeEnts = Pool.Get <List <ArcadeGame.arcadeEnt> >();
     }
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num != 10)
         {
             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);
         }
         else
         {
             instance.arcadeEnts.Add(ArcadeGame.arcadeEnt.DeserializeLengthDelimited(stream));
         }
     }
     return(instance);
 }
Пример #6
0
 public static ArcadeGame Deserialize(byte[] buffer, ArcadeGame instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         ArcadeGame.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
Пример #7
0
 public virtual void WriteToStreamDelta(Stream stream, ArcadeGame previous)
 {
     if (previous == null)
     {
         ArcadeGame.Serialize(stream, this);
         return;
     }
     ArcadeGame.SerializeDelta(stream, this, previous);
 }
Пример #8
0
        public static ArcadeGame Deserialize(byte[] buffer)
        {
            ArcadeGame arcadeGame = Pool.Get <ArcadeGame>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                ArcadeGame.Deserialize(memoryStream, arcadeGame, false);
            }
            return(arcadeGame);
        }
Пример #9
0
 public static byte[] SerializeToBytes(ArcadeGame instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         ArcadeGame.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
Пример #10
0
        public static void SerializeDelta(Stream stream, ArcadeGame instance, ArcadeGame previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.arcadeEnts != null)
            {
                for (int i = 0; i < instance.arcadeEnts.Count; i++)
                {
                    ArcadeGame.arcadeEnt item = instance.arcadeEnts[i];
                    stream.WriteByte(10);
                    memoryStream.SetLength((long)0);
                    ArcadeGame.arcadeEnt.SerializeDelta(memoryStream, item, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
Пример #11
0
 public static void ResetToPool(ArcadeGame instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     if (instance.arcadeEnts != null)
     {
         for (int i = 0; i < instance.arcadeEnts.Count; i++)
         {
             if (instance.arcadeEnts[i] != null)
             {
                 instance.arcadeEnts[i].ResetToPool();
                 instance.arcadeEnts[i] = null;
             }
         }
         List <ArcadeGame.arcadeEnt> arcadeEnts = instance.arcadeEnts;
         Pool.FreeList <ArcadeGame.arcadeEnt>(ref arcadeEnts);
         instance.arcadeEnts = arcadeEnts;
     }
     Pool.Free <ArcadeGame>(ref instance);
 }
Пример #12
0
 public virtual void WriteToStream(Stream stream)
 {
     ArcadeGame.Serialize(stream, this);
 }
Пример #13
0
 public byte[] ToProtoBytes()
 {
     return(ArcadeGame.SerializeToBytes(this));
 }
Пример #14
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     ArcadeGame.Deserialize(stream, this, isDelta);
 }
Пример #15
0
 public static void SerializeLengthDelimited(Stream stream, ArcadeGame instance)
 {
     byte[] bytes = ArcadeGame.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
Пример #16
0
 public void ResetToPool()
 {
     ArcadeGame.ResetToPool(this);
 }
Пример #17
0
 public void CopyTo(ArcadeGame instance)
 {
     throw new NotImplementedException();
 }
Пример #18
0
 public void ToProto(Stream stream)
 {
     ArcadeGame.Serialize(stream, this);
 }
Пример #19
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     ArcadeGame.DeserializeLength(stream, size, this, isDelta);
 }