Exemplo n.º 1
0
 public static ResearchTable Deserialize(Stream stream, ResearchTable instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num != 13)
         {
             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.researchTimeLeft = ProtocolParser.ReadSingle(stream);
         }
     }
     return(instance);
 }
Exemplo n.º 2
0
        public static ResearchTable DeserializeLength(Stream stream, int length, ResearchTable instance, bool isDelta)
        {
            long position = stream.Position + (long)length;

            while (stream.Position < position)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    throw new EndOfStreamException();
                }
                if (num != 13)
                {
                    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.researchTimeLeft = ProtocolParser.ReadSingle(stream);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
Exemplo n.º 3
0
        public static ResearchTable DeserializeLength(Stream stream, int length)
        {
            ResearchTable researchTable = Pool.Get <ResearchTable>();

            ResearchTable.DeserializeLength(stream, length, researchTable, false);
            return(researchTable);
        }
Exemplo n.º 4
0
        public static ResearchTable Deserialize(Stream stream)
        {
            ResearchTable researchTable = Pool.Get <ResearchTable>();

            ResearchTable.Deserialize(stream, researchTable, false);
            return(researchTable);
        }
Exemplo n.º 5
0
        public ResearchTable Copy()
        {
            ResearchTable researchTable = Pool.Get <ResearchTable>();

            this.CopyTo(researchTable);
            return(researchTable);
        }
Exemplo n.º 6
0
 public static ResearchTable Deserialize(byte[] buffer, ResearchTable instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         ResearchTable.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
Exemplo n.º 7
0
        public static void Serialize(Stream stream, ResearchTable instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(13);
            ProtocolParser.WriteSingle(stream, instance.researchTimeLeft);
            Pool.FreeMemoryStream(ref memoryStream);
        }
Exemplo n.º 8
0
 public virtual void WriteToStreamDelta(Stream stream, ResearchTable previous)
 {
     if (previous == null)
     {
         ResearchTable.Serialize(stream, this);
         return;
     }
     ResearchTable.SerializeDelta(stream, this, previous);
 }
Exemplo n.º 9
0
 public static void ResetToPool(ResearchTable instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.researchTimeLeft = 0f;
     Pool.Free <ResearchTable>(ref instance);
 }
Exemplo n.º 10
0
        public static ResearchTable Deserialize(byte[] buffer)
        {
            ResearchTable researchTable = Pool.Get <ResearchTable>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                ResearchTable.Deserialize(memoryStream, researchTable, false);
            }
            return(researchTable);
        }
Exemplo n.º 11
0
 public static byte[] SerializeToBytes(ResearchTable instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         ResearchTable.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
Exemplo n.º 12
0
        public static void SerializeDelta(Stream stream, ResearchTable instance, ResearchTable previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.researchTimeLeft != previous.researchTimeLeft)
            {
                stream.WriteByte(13);
                ProtocolParser.WriteSingle(stream, instance.researchTimeLeft);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
Exemplo n.º 13
0
 public void ToProto(Stream stream)
 {
     ResearchTable.Serialize(stream, this);
 }
Exemplo n.º 14
0
 public void CopyTo(ResearchTable instance)
 {
     instance.researchTimeLeft = this.researchTimeLeft;
 }
Exemplo n.º 15
0
 public virtual void WriteToStream(Stream stream)
 {
     ResearchTable.Serialize(stream, this);
 }
Exemplo n.º 16
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     ResearchTable.DeserializeLength(stream, size, this, isDelta);
 }
Exemplo n.º 17
0
 public static void SerializeLengthDelimited(Stream stream, ResearchTable instance)
 {
     byte[] bytes = ResearchTable.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
Exemplo n.º 18
0
 public void ResetToPool()
 {
     ResearchTable.ResetToPool(this);
 }
Exemplo n.º 19
0
 public byte[] ToProtoBytes()
 {
     return(ResearchTable.SerializeToBytes(this));
 }
Exemplo n.º 20
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     ResearchTable.Deserialize(stream, this, isDelta);
 }