public static void SerializeDelta(Stream stream, CodeLock.Private instance, CodeLock.Private previous)
            {
                MemoryStream memoryStream = Pool.Get <MemoryStream>();

                if (instance.code != null && instance.code != previous.code)
                {
                    stream.WriteByte(10);
                    ProtocolParser.WriteString(stream, instance.code);
                }
                if (instance.users != null)
                {
                    for (int i = 0; i < instance.users.Count; i++)
                    {
                        ulong item = instance.users[i];
                        stream.WriteByte(16);
                        ProtocolParser.WriteUInt64(stream, item);
                    }
                }
                if (instance.guestCode != null && instance.guestCode != previous.guestCode)
                {
                    stream.WriteByte(34);
                    ProtocolParser.WriteString(stream, instance.guestCode);
                }
                if (instance.guestUsers != null)
                {
                    for (int j = 0; j < instance.guestUsers.Count; j++)
                    {
                        ulong num = instance.guestUsers[j];
                        stream.WriteByte(40);
                        ProtocolParser.WriteUInt64(stream, num);
                    }
                }
                Pool.FreeMemoryStream(ref memoryStream);
            }
            public static CodeLock.Private DeserializeLengthDelimited(Stream stream, CodeLock.Private instance, bool isDelta)
            {
                if (!isDelta)
                {
                    if (instance.users == null)
                    {
                        instance.users = Pool.Get <List <ulong> >();
                    }
                    if (instance.guestUsers == null)
                    {
                        instance.guestUsers = Pool.Get <List <ulong> >();
                    }
                }
                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 <= 16)
                    {
                        if (num == 10)
                        {
                            instance.code = ProtocolParser.ReadString(stream);
                            continue;
                        }
                        else if (num == 16)
                        {
                            instance.users.Add(ProtocolParser.ReadUInt64(stream));
                            continue;
                        }
                    }
                    else if (num == 34)
                    {
                        instance.guestCode = ProtocolParser.ReadString(stream);
                        continue;
                    }
                    else if (num == 40)
                    {
                        instance.guestUsers.Add(ProtocolParser.ReadUInt64(stream));
                        continue;
                    }
                    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);
            }
 public static CodeLock.Private Deserialize(byte[] buffer, CodeLock.Private instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         CodeLock.Private.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
 public virtual void WriteToStreamDelta(Stream stream, CodeLock.Private previous)
 {
     if (previous == null)
     {
         CodeLock.Private.Serialize(stream, this);
         return;
     }
     CodeLock.Private.SerializeDelta(stream, this, previous);
 }
 public static CodeLock.Private Deserialize(byte[] buffer)
 {
     CodeLock.Private @private = Pool.Get <CodeLock.Private>();
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         CodeLock.Private.Deserialize(memoryStream, @private, false);
     }
     return(@private);
 }
 public static byte[] SerializeToBytes(CodeLock.Private instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         CodeLock.Private.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
 public static CodeLock.Private Deserialize(Stream stream, CodeLock.Private instance, bool isDelta)
 {
     if (!isDelta)
     {
         if (instance.users == null)
         {
             instance.users = Pool.Get <List <ulong> >();
         }
         if (instance.guestUsers == null)
         {
             instance.guestUsers = Pool.Get <List <ulong> >();
         }
     }
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num <= 16)
         {
             if (num == 10)
             {
                 instance.code = ProtocolParser.ReadString(stream);
                 continue;
             }
             else if (num == 16)
             {
                 instance.users.Add(ProtocolParser.ReadUInt64(stream));
                 continue;
             }
         }
         else if (num == 34)
         {
             instance.guestCode = ProtocolParser.ReadString(stream);
             continue;
         }
         else if (num == 40)
         {
             instance.guestUsers.Add(ProtocolParser.ReadUInt64(stream));
             continue;
         }
         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);
 }
 public static void ResetToPool(CodeLock.Private instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.code = string.Empty;
     if (instance.users != null)
     {
         List <ulong> nums = instance.users;
         Pool.FreeList <ulong>(ref nums);
         instance.users = nums;
     }
     instance.guestCode = string.Empty;
     if (instance.guestUsers != null)
     {
         List <ulong> nums1 = instance.guestUsers;
         Pool.FreeList <ulong>(ref nums1);
         instance.guestUsers = nums1;
     }
     Pool.Free <CodeLock.Private>(ref instance);
 }
 public static void SerializeLengthDelimited(Stream stream, CodeLock.Private instance)
 {
     byte[] bytes = CodeLock.Private.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
 public static CodeLock.Private DeserializeLengthDelimited(Stream stream)
 {
     CodeLock.Private @private = Pool.Get <CodeLock.Private>();
     CodeLock.Private.DeserializeLengthDelimited(stream, @private, false);
     return(@private);
 }
 public static CodeLock.Private DeserializeLength(Stream stream, int length)
 {
     CodeLock.Private @private = Pool.Get <CodeLock.Private>();
     CodeLock.Private.DeserializeLength(stream, length, @private, false);
     return(@private);
 }
 public void CopyTo(CodeLock.Private instance)
 {
     instance.code = this.code;
     throw new NotImplementedException();
 }
 public CodeLock.Private Copy()
 {
     CodeLock.Private @private = Pool.Get <CodeLock.Private>();
     this.CopyTo(@private);
     return(@private);
 }