BinaryReaderExtensions.cs 412 B

12345678910111213141516
  1. using System;
  2. using System.IO;
  3. using System.Runtime.CompilerServices;
  4. using System.Runtime.InteropServices;
  5. namespace Ryujinx.Common
  6. {
  7. public static class BinaryReaderExtensions
  8. {
  9. public unsafe static T ReadStruct<T>(this BinaryReader reader)
  10. where T : unmanaged
  11. {
  12. return MemoryMarshal.Cast<byte, T>(reader.ReadBytes(Unsafe.SizeOf<T>()))[0];
  13. }
  14. }
  15. }