Пример #1
0
        public static CodeLock Deserialize(Stream stream)
        {
            CodeLock codeLock = Pool.Get <CodeLock>();

            CodeLock.Deserialize(stream, codeLock, false);
            return(codeLock);
        }
Пример #2
0
        public CodeLock Copy()
        {
            CodeLock codeLock = Pool.Get <CodeLock>();

            this.CopyTo(codeLock);
            return(codeLock);
        }
Пример #3
0
        public static CodeLock DeserializeLength(Stream stream, int length)
        {
            CodeLock codeLock = Pool.Get <CodeLock>();

            CodeLock.DeserializeLength(stream, length, codeLock, false);
            return(codeLock);
        }
Пример #4
0
 public static CodeLock Deserialize(byte[] buffer, CodeLock instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         CodeLock.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
Пример #5
0
 public virtual void WriteToStreamDelta(Stream stream, CodeLock previous)
 {
     if (previous == null)
     {
         CodeLock.Serialize(stream, this);
         return;
     }
     CodeLock.SerializeDelta(stream, this, previous);
 }
Пример #6
0
 public static byte[] SerializeToBytes(CodeLock instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         CodeLock.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
Пример #7
0
        public static CodeLock Deserialize(byte[] buffer)
        {
            CodeLock codeLock = Pool.Get <CodeLock>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                CodeLock.Deserialize(memoryStream, codeLock, false);
            }
            return(codeLock);
        }
Пример #8
0
 public static void ResetToPool(CodeLock instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     if (instance.pv != null)
     {
         instance.pv.ResetToPool();
         instance.pv = null;
     }
     instance.hasCode      = false;
     instance.hasGuestCode = false;
     Pool.Free <CodeLock>(ref instance);
 }
Пример #9
0
        public static CodeLock DeserializeLengthDelimited(Stream stream, CodeLock 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 == 10)
                {
                    if (instance.pv != null)
                    {
                        CodeLock.Private.DeserializeLengthDelimited(stream, instance.pv, isDelta);
                    }
                    else
                    {
                        instance.pv = CodeLock.Private.DeserializeLengthDelimited(stream);
                    }
                }
                else if (num == 16)
                {
                    instance.hasCode = ProtocolParser.ReadBool(stream);
                }
                else if (num == 24)
                {
                    instance.hasGuestCode = 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);
        }
Пример #10
0
 public void CopyTo(CodeLock instance)
 {
     if (this.pv == null)
     {
         instance.pv = null;
     }
     else if (instance.pv != null)
     {
         this.pv.CopyTo(instance.pv);
     }
     else
     {
         instance.pv = this.pv.Copy();
     }
     instance.hasCode      = this.hasCode;
     instance.hasGuestCode = this.hasGuestCode;
 }
Пример #11
0
        public static void SerializeDelta(Stream stream, CodeLock instance, CodeLock previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.pv != null)
            {
                stream.WriteByte(10);
                memoryStream.SetLength((long)0);
                CodeLock.Private.SerializeDelta(memoryStream, instance.pv, previous.pv);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            stream.WriteByte(16);
            ProtocolParser.WriteBool(stream, instance.hasCode);
            stream.WriteByte(24);
            ProtocolParser.WriteBool(stream, instance.hasGuestCode);
            Pool.FreeMemoryStream(ref memoryStream);
        }
Пример #12
0
 public static CodeLock Deserialize(Stream stream, CodeLock instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num == 10)
         {
             if (instance.pv != null)
             {
                 CodeLock.Private.DeserializeLengthDelimited(stream, instance.pv, isDelta);
             }
             else
             {
                 instance.pv = CodeLock.Private.DeserializeLengthDelimited(stream);
             }
         }
         else if (num == 16)
         {
             instance.hasCode = ProtocolParser.ReadBool(stream);
         }
         else if (num == 24)
         {
             instance.hasGuestCode = 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);
         }
     }
     return(instance);
 }
Пример #13
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     CodeLock.Deserialize(stream, this, isDelta);
 }
Пример #14
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     CodeLock.DeserializeLength(stream, size, this, isDelta);
 }
Пример #15
0
 public virtual void WriteToStream(Stream stream)
 {
     CodeLock.Serialize(stream, this);
 }
Пример #16
0
 public byte[] ToProtoBytes()
 {
     return(CodeLock.SerializeToBytes(this));
 }
Пример #17
0
 public void ToProto(Stream stream)
 {
     CodeLock.Serialize(stream, this);
 }
Пример #18
0
 public static void SerializeLengthDelimited(Stream stream, CodeLock instance)
 {
     byte[] bytes = CodeLock.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
Пример #19
0
 public void ResetToPool()
 {
     CodeLock.ResetToPool(this);
 }