Skip to content

Commit

Permalink
including missing file from previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
markheath committed Mar 11, 2016
1 parent c342e11 commit 392afe7
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions NAudio.Universal/Utils/MarshalHelpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;

// ReSharper disable once CheckNamespace
namespace NAudio.Utils
{
/// <summary>
/// Support for Marshal Methods in both UWP and .NET 3.5
/// </summary>
public static class MarshalHelpers
{
/// <summary>
/// SizeOf a structure
/// </summary>
public static int SizeOf<T>()
{
return Marshal.SizeOf<T>();
}

/// <summary>
/// Offset of a field in a structure
/// </summary>
public static IntPtr OffsetOf<T>(string fieldName)
{
return Marshal.OffsetOf<T>(fieldName);
}

/// <summary>
/// Pointer to Structure
/// </summary>
public static T PtrToStructure<T>(IntPtr pointer)
{
return Marshal.PtrToStructure<T>(pointer);
}
}
}

0 comments on commit 392afe7

Please sign in to comment.