public static ClientReady DeserializeLength(Stream stream, int length) { ClientReady clientReady = Pool.Get <ClientReady>(); ClientReady.DeserializeLength(stream, length, clientReady, false); return(clientReady); }
public static ClientReady DeserializeLength(Stream stream, int length, ClientReady instance, bool isDelta) { if (!isDelta && instance.clientInfo == null) { instance.clientInfo = Pool.Get <List <ClientReady.ClientInfo> >(); } 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.clientInfo.Add(ClientReady.ClientInfo.DeserializeLengthDelimited(stream)); } } if (stream.Position != position) { throw new ProtocolBufferException("Read past max limit"); } return(instance); }
public static ClientReady Deserialize(Stream stream, ClientReady instance, bool isDelta) { if (!isDelta && instance.clientInfo == null) { instance.clientInfo = Pool.Get <List <ClientReady.ClientInfo> >(); } 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.clientInfo.Add(ClientReady.ClientInfo.DeserializeLengthDelimited(stream)); } } return(instance); }
public static ClientReady Deserialize(Stream stream) { ClientReady clientReady = Pool.Get <ClientReady>(); ClientReady.Deserialize(stream, clientReady, false); return(clientReady); }
public ClientReady Copy() { ClientReady clientReady = Pool.Get <ClientReady>(); this.CopyTo(clientReady); return(clientReady); }
public static ClientReady Deserialize(byte[] buffer, ClientReady instance, bool isDelta = false) { using (MemoryStream memoryStream = new MemoryStream(buffer)) { ClientReady.Deserialize(memoryStream, instance, isDelta); } return(instance); }
public virtual void WriteToStreamDelta(Stream stream, ClientReady previous) { if (previous == null) { ClientReady.Serialize(stream, this); return; } ClientReady.SerializeDelta(stream, this, previous); }
public static ClientReady Deserialize(byte[] buffer) { ClientReady clientReady = Pool.Get <ClientReady>(); using (MemoryStream memoryStream = new MemoryStream(buffer)) { ClientReady.Deserialize(memoryStream, clientReady, false); } return(clientReady); }
public static byte[] SerializeToBytes(ClientReady instance) { byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { ClientReady.Serialize(memoryStream, instance); array = memoryStream.ToArray(); } return(array); }
public static void SerializeDelta(Stream stream, ClientReady instance, ClientReady previous) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); if (instance.clientInfo != null) { for (int i = 0; i < instance.clientInfo.Count; i++) { ClientReady.ClientInfo item = instance.clientInfo[i]; stream.WriteByte(10); memoryStream.SetLength((long)0); ClientReady.ClientInfo.SerializeDelta(memoryStream, item, item); uint length = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length); stream.Write(memoryStream.GetBuffer(), 0, (int)length); } } Pool.FreeMemoryStream(ref memoryStream); }
public static void ResetToPool(ClientReady instance) { if (!instance.ShouldPool) { return; } if (instance.clientInfo != null) { for (int i = 0; i < instance.clientInfo.Count; i++) { if (instance.clientInfo[i] != null) { instance.clientInfo[i].ResetToPool(); instance.clientInfo[i] = null; } } List <ClientReady.ClientInfo> clientInfos = instance.clientInfo; Pool.FreeList <ClientReady.ClientInfo>(ref clientInfos); instance.clientInfo = clientInfos; } Pool.Free <ClientReady>(ref instance); }
public virtual void WriteToStream(Stream stream) { ClientReady.Serialize(stream, this); }
public byte[] ToProtoBytes() { return(ClientReady.SerializeToBytes(this)); }
public void FromProto(Stream stream, bool isDelta = false) { ClientReady.Deserialize(stream, this, isDelta); }
public static void SerializeLengthDelimited(Stream stream, ClientReady instance) { byte[] bytes = ClientReady.SerializeToBytes(instance); ProtocolParser.WriteUInt32(stream, (uint)bytes.Length); stream.Write(bytes, 0, (int)bytes.Length); }
public void ResetToPool() { ClientReady.ResetToPool(this); }
public void ToProto(Stream stream) { ClientReady.Serialize(stream, this); }
public void CopyTo(ClientReady instance) { throw new NotImplementedException(); }
public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false) { ClientReady.DeserializeLength(stream, size, this, isDelta); }