public static ServerGib Deserialize(Stream stream, ServerGib instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num != 10)
         {
             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.gibName = ProtocolParser.ReadString(stream);
         }
     }
     return(instance);
 }
        public static ServerGib DeserializeLength(Stream stream, int length, ServerGib 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 != 10)
                {
                    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.gibName = ProtocolParser.ReadString(stream);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
        public static ServerGib Deserialize(Stream stream)
        {
            ServerGib serverGib = Pool.Get <ServerGib>();

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

            this.CopyTo(serverGib);
            return(serverGib);
        }
        public static ServerGib DeserializeLength(Stream stream, int length)
        {
            ServerGib serverGib = Pool.Get <ServerGib>();

            ServerGib.DeserializeLength(stream, length, serverGib, false);
            return(serverGib);
        }
 public static ServerGib Deserialize(byte[] buffer, ServerGib instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         ServerGib.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
 public virtual void WriteToStreamDelta(Stream stream, ServerGib previous)
 {
     if (previous == null)
     {
         ServerGib.Serialize(stream, this);
         return;
     }
     ServerGib.SerializeDelta(stream, this, previous);
 }
 public static void ResetToPool(ServerGib instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.gibName = string.Empty;
     Pool.Free <ServerGib>(ref instance);
 }
        public static ServerGib Deserialize(byte[] buffer)
        {
            ServerGib serverGib = Pool.Get <ServerGib>();

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

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