示例#1
0
 public static Lift Deserialize(Stream stream, Lift instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num != 8)
         {
             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.floor = (int)ProtocolParser.ReadUInt64(stream);
         }
     }
     return(instance);
 }
示例#2
0
        public static Lift DeserializeLength(Stream stream, int length, Lift 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 != 8)
                {
                    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.floor = (int)ProtocolParser.ReadUInt64(stream);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
示例#3
0
        public static Lift DeserializeLength(Stream stream, int length)
        {
            Lift lift = Pool.Get <Lift>();

            Lift.DeserializeLength(stream, length, lift, false);
            return(lift);
        }
示例#4
0
        public static Lift Deserialize(Stream stream)
        {
            Lift lift = Pool.Get <Lift>();

            Lift.Deserialize(stream, lift, false);
            return(lift);
        }
示例#5
0
        public Lift Copy()
        {
            Lift lift = Pool.Get <Lift>();

            this.CopyTo(lift);
            return(lift);
        }
示例#6
0
 public static Lift Deserialize(byte[] buffer, Lift instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         Lift.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
示例#7
0
        public static void Serialize(Stream stream, Lift instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(8);
            ProtocolParser.WriteUInt64(stream, (ulong)instance.floor);
            Pool.FreeMemoryStream(ref memoryStream);
        }
示例#8
0
 public virtual void WriteToStreamDelta(Stream stream, Lift previous)
 {
     if (previous == null)
     {
         Lift.Serialize(stream, this);
         return;
     }
     Lift.SerializeDelta(stream, this, previous);
 }
示例#9
0
 public static void ResetToPool(Lift instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.floor = 0;
     Pool.Free <Lift>(ref instance);
 }
示例#10
0
        public static Lift Deserialize(byte[] buffer)
        {
            Lift lift = Pool.Get <Lift>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                Lift.Deserialize(memoryStream, lift, false);
            }
            return(lift);
        }
示例#11
0
 public static byte[] SerializeToBytes(Lift instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         Lift.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
示例#12
0
        public static void SerializeDelta(Stream stream, Lift instance, Lift previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

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