MarshalExtensions.cs 544 B

1234567891011121314151617181920212223
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace SoundIOSharp
  4. {
  5. public static class MarshalEx
  6. {
  7. public static double ReadDouble (IntPtr handle, int offset = 0)
  8. {
  9. return BitConverter.Int64BitsToDouble (Marshal.ReadInt64 (handle, offset));
  10. }
  11. public static void WriteDouble (IntPtr handle, double value)
  12. {
  13. WriteDouble (handle, 0, value);
  14. }
  15. public static void WriteDouble (IntPtr handle, int offset, double value)
  16. {
  17. Marshal.WriteInt64 (handle, offset, BitConverter.DoubleToInt64Bits (value));
  18. }
  19. }
  20. }