public static KeyLock Deserialize(Stream stream, KeyLock 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.code = (int)ProtocolParser.ReadUInt64(stream);
         }
     }
     return(instance);
 }
        public static KeyLock DeserializeLength(Stream stream, int length, KeyLock 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.code = (int)ProtocolParser.ReadUInt64(stream);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
        public static KeyLock DeserializeLength(Stream stream, int length)
        {
            KeyLock keyLock = Pool.Get <KeyLock>();

            KeyLock.DeserializeLength(stream, length, keyLock, false);
            return(keyLock);
        }
        public static KeyLock Deserialize(Stream stream)
        {
            KeyLock keyLock = Pool.Get <KeyLock>();

            KeyLock.Deserialize(stream, keyLock, false);
            return(keyLock);
        }
        public KeyLock Copy()
        {
            KeyLock keyLock = Pool.Get <KeyLock>();

            this.CopyTo(keyLock);
            return(keyLock);
        }
 public static KeyLock Deserialize(byte[] buffer, KeyLock instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         KeyLock.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
        public static void Serialize(Stream stream, KeyLock instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

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

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                KeyLock.Deserialize(memoryStream, keyLock, false);
            }
            return(keyLock);
        }
 public static byte[] SerializeToBytes(KeyLock instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         KeyLock.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
        public static void SerializeDelta(Stream stream, KeyLock instance, KeyLock previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.code != previous.code)
            {
                stream.WriteByte(8);
                ProtocolParser.WriteUInt64(stream, (ulong)instance.code);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
 public void ToProto(Stream stream)
 {
     KeyLock.Serialize(stream, this);
 }
 public void CopyTo(KeyLock instance)
 {
     instance.code = this.code;
 }
 public virtual void WriteToStream(Stream stream)
 {
     KeyLock.Serialize(stream, this);
 }
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     KeyLock.DeserializeLength(stream, size, this, isDelta);
 }
 public static void SerializeLengthDelimited(Stream stream, KeyLock instance)
 {
     byte[] bytes = KeyLock.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
 public void ResetToPool()
 {
     KeyLock.ResetToPool(this);
 }
 public byte[] ToProtoBytes()
 {
     return(KeyLock.SerializeToBytes(this));
 }
 public void FromProto(Stream stream, bool isDelta = false)
 {
     KeyLock.Deserialize(stream, this, isDelta);
 }