public static EntityList Deserialize(Stream stream, EntityList instance, bool isDelta) { if (!isDelta && instance.entity == null) { instance.entity = Pool.Get <List <Entity> >(); } 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.entity.Add(Entity.DeserializeLengthDelimited(stream)); } } return(instance); }
public static EntityList DeserializeLength(Stream stream, int length, EntityList instance, bool isDelta) { if (!isDelta && instance.entity == null) { instance.entity = Pool.Get <List <Entity> >(); } 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.entity.Add(Entity.DeserializeLengthDelimited(stream)); } } if (stream.Position != position) { throw new ProtocolBufferException("Read past max limit"); } return(instance); }