Ejemplo n.º 1
0
        public static void Serialize(Stream stream, BuildingBlock instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(8);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.model);
            stream.WriteByte(16);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.grade);
            stream.WriteByte(24);
            ProtocolParser.WriteBool(stream, instance.beingDemolished);
            Pool.FreeMemoryStream(ref memoryStream);
        }
Ejemplo n.º 2
0
        public static BuildingBlock DeserializeLengthDelimited(Stream stream, BuildingBlock 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.model = (int)ProtocolParser.ReadUInt64(stream);
                }
                else if (num == 16)
                {
                    instance.grade = (int)ProtocolParser.ReadUInt64(stream);
                }
                else if (num == 24)
                {
                    instance.beingDemolished = ProtocolParser.ReadBool(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);
        }
Ejemplo n.º 3
0
 public void CopyTo(BuildingBlock instance)
 {
     instance.model           = this.model;
     instance.grade           = this.grade;
     instance.beingDemolished = this.beingDemolished;
 }
Ejemplo n.º 4
0
 public virtual void WriteToStream(Stream stream)
 {
     BuildingBlock.Serialize(stream, this);
 }
Ejemplo n.º 5
0
 public byte[] ToProtoBytes()
 {
     return(BuildingBlock.SerializeToBytes(this));
 }
Ejemplo n.º 6
0
 public void ToProto(Stream stream)
 {
     BuildingBlock.Serialize(stream, this);
 }
Ejemplo n.º 7
0
 public static void SerializeLengthDelimited(Stream stream, BuildingBlock instance)
 {
     byte[] bytes = BuildingBlock.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
Ejemplo n.º 8
0
 public void ResetToPool()
 {
     BuildingBlock.ResetToPool(this);
 }
Ejemplo n.º 9
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     BuildingBlock.DeserializeLength(stream, size, this, isDelta);
 }
Ejemplo n.º 10
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     BuildingBlock.Deserialize(stream, this, isDelta);
 }