public static T[] ReadArray <T>(this BinaryReader reader, int size) where T : struct { int numBytes = Marshal.SizeOf <T>() * size; byte[] result = reader.ReadBytes(numBytes); return(FastStruct <T> .ReadArray(result)); }
public T[] ReadArray <T>(MemoryStream ms, int size) where T : struct { int numBytes = Marshal.SizeOf <T>() * size; byte[] result = new byte[numBytes]; ms.Read(result, 0, numBytes); return(FastStruct <T> .ReadArray(result)); }
public static T[] ReadArray <T>(this BinaryReader reader) where T : struct { int numBytes = (int)reader.ReadInt64(); byte[] result = reader.ReadBytes(numBytes); reader.BaseStream.Position += (0 - numBytes) & 0x07; return(FastStruct <T> .ReadArray(result)); }
public T[] ReadArray <T>(MemoryStream ms) where T : struct { int numBytes = (int)ReadInt64(ms); byte[] result = new byte[numBytes]; ms.Read(result, 0, numBytes); ms.Position += (0 - numBytes) & 0x07; return(FastStruct <T> .ReadArray(result)); }
/// <summary> /// Read array of structs from a reader /// </summary> /// <param name="reader">Target reader</param> /// <param name="count">Count</param> /// <typeparam name="T">Struct to read</typeparam> /// <returns>Stuct array</returns> public static T[] ReadArray <T>(this BinaryReader reader, int count) where T : struct { if (count == 0) { return(new T[0]); } int numBytes = FastStruct <T> .Size * count; byte[] result = reader.ReadBytes(numBytes); return(FastStruct <T> .ReadArray(result)); }