using System; using System.Runtime.InteropServices; namespace NAudio.Utils { /// /// Support for Marshal Methods in both UWP and .NET 3.5 /// public static class MarshalHelpers { /// /// SizeOf a structure /// public static int SizeOf() { return Marshal.SizeOf(typeof (T)); } /// /// Offset of a field in a structure /// public static IntPtr OffsetOf(string fieldName) { return Marshal.OffsetOf(typeof(T), fieldName); } /// /// Pointer to Structure /// public static T PtrToStructure(IntPtr pointer) { return (T)Marshal.PtrToStructure(pointer, typeof(T)); } } }