// Licensed to Timothy Schenk under the GNU AGPL Version 3 License. using System.Text; namespace Wonderking.Game.Reader; public static class GenericReaderExtensions { public static string ReadString(this BinaryReader reader, int length) { var ret = Encoding.ASCII.GetString(reader.ReadBytes(length)).Replace("\0", "", StringComparison.Ordinal); return ret; } public static T[] ReadArray(this BinaryReader pReader, int pLength) where T : new() { var array = new T[pLength]; for (var index = 0; index < pLength; ++index) { array[index] = pReader.Read(); } return array; } public static T Read(this BinaryReader br) where T : new() { return BinaryReader.Read(br); } }