// // Licensed under the MIT License. See LICENSE file in the project root for full license information. // namespace MUnique.OpenMU.Network; using System.IO; /// /// Extensions for streams. /// public static class StreamExtensions { /// /// Reads an integer from the current position of a stream. /// /// The stream. /// The integer from the stream. /// Length: {stream.Length}; Position: {stream.Position}. public static uint ReadInteger(this Stream stream) { if (stream.Length < stream.Position + sizeof(uint)) { throw new EndOfStreamException($"Length: {stream.Length}; Position: {stream.Position}"); } return NumberConversionExtensions.MakeDword((byte)stream.ReadByte(), (byte)stream.ReadByte(), (byte)stream.ReadByte(), (byte)stream.ReadByte()); } }