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); }
public static byte[] SerializeToBytes(ServerGib instance) { byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { ServerGib.Serialize(memoryStream, instance); array = memoryStream.ToArray(); } return(array); }
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); }
public void ToProto(Stream stream) { ServerGib.Serialize(stream, this); }
public void CopyTo(ServerGib instance) { instance.gibName = this.gibName; }
public virtual void WriteToStream(Stream stream) { ServerGib.Serialize(stream, this); }
public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false) { ServerGib.DeserializeLength(stream, size, this, isDelta); }
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); }
public void ResetToPool() { ServerGib.ResetToPool(this); }
public byte[] ToProtoBytes() { return(ServerGib.SerializeToBytes(this)); }
public void FromProto(Stream stream, bool isDelta = false) { ServerGib.Deserialize(stream, this, isDelta); }