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