/// <summary>Read the VarInt length prefix and the given number of bytes from the stream and deserialze it into the instance.</summary> public static LocalFeatureTest.InterfaceTest DeserializeLengthDelimited(Stream stream, LocalFeatureTest.InterfaceTest instance) { long limit = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt32(stream); limit += stream.Position; while (true) { if (stream.Position >= limit) { if (stream.Position == limit) break; else throw new InvalidOperationException("Read past max limit"); } int keyByte = stream.ReadByte(); if (keyByte == -1) throw new System.IO.EndOfStreamException(); var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream); // Reading field ID > 16 and unknown field ID/wire type combinations switch (key.Field) { case 0: throw new InvalidDataException("Invalid field id: 0, something went wrong in the stream"); default: global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key); break; } } return instance; }
/// <summary>Helper: put the buffer into a MemoryStream before deserializing</summary> public static LocalFeatureTest.InterfaceTest Deserialize(byte[] buffer, LocalFeatureTest.InterfaceTest instance) { using (var ms = new MemoryStream(buffer)) Deserialize(ms, instance); return instance; }
/// <summary>Takes the remaining content of the stream and deserialze it into the instance.</summary> public static LocalFeatureTest.InterfaceTest Deserialize(Stream stream, LocalFeatureTest.InterfaceTest instance) { while (true) { int keyByte = stream.ReadByte(); if (keyByte == -1) break; var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream); // Reading field ID > 16 and unknown field ID/wire type combinations switch (key.Field) { case 0: throw new InvalidDataException("Invalid field id: 0, something went wrong in the stream"); default: global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key); break; } } return instance; }
/// <summary>Helper: put the buffer into a MemoryStream before deserializing</summary> public static LocalFeatureTest.StructTest Deserialize(byte[] buffer, ref LocalFeatureTest.StructTest instance) { using (var ms = new MemoryStream(buffer)) Deserialize(ms, ref instance); return instance; }