PkmnLibSharp/PkmnLibSharp/Utilities/MarshalHelper.cs

32 lines
741 B
C#
Raw Normal View History

2020-05-02 20:58:08 +00:00
using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace PkmnLibSharp.Utilities
{
internal static class MarshalHelper
{
internal static IntPtr ToPtr(this string s)
{
return Marshal.StringToHGlobalAuto(s);
}
internal static string PtrString(this IntPtr i)
{
return Marshal.PtrToStringAuto(i);
}
internal static IntPtr ArrayPtr(this Array a)
{
return Marshal.UnsafeAddrOfPinnedArrayElement(a, 0);
}
2020-05-03 09:38:49 +00:00
internal const byte True = 1;
internal const byte False = 0;
internal static byte ToNative(this bool b)
{
return b ? True : False;
}
2020-05-02 20:58:08 +00:00
}
}