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