예제 #1
0
        public unsafe static T Read <T>(this BinaryReader reader) where T : struct
        {
            byte[] result = reader.ReadBytes(FastStruct <T> .Size);

            fixed(byte *ptr = result)
            return(FastStruct <T> .PtrToStructure(ptr));
        }
예제 #2
0
        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));
        }
예제 #3
0
        public unsafe static T[] ReadArray <T>(this BinaryReader reader) where T : struct
        {
            int numBytes = (int)reader.ReadInt64();

            byte[] result = reader.ReadBytes(numBytes);

            fixed(byte *ptr = result)
            {
                T[] data = FastStruct <T> .ReadArray((IntPtr)ptr, numBytes);

                reader.BaseStream.Position += (0 - numBytes) & 0x07;
                return(data);
            }
        }
예제 #4
0
        public static T Read <T>(this BinaryReader reader) where T : struct
        {
            byte[] result = reader.ReadBytes(FastStruct <T> .Size);

            return(FastStruct <T> .ArrayToStructure(result));
        }