Sharp.Augeas/CodeLiturgy.Augeas/test/AugSettings_Wrapper.cs

43 lines
886 B
C#
Raw Normal View History

2022-11-04 03:40:02 +03:00
using System.Runtime.InteropServices;
namespace CodeLiturgy.Augeas.Test;
class AugSettings_Wrapper : IDisposable
{
private GCHandle m_loadPath_hand;
private string m_loadPath;
public AugSettings_Wrapper( string loadPath)
{
m_loadPath = new string(loadPath);
m_loadPath_hand = GCHandle.Alloc(m_loadPath, GCHandleType.Pinned);
}
public AugSettings GetUnamangedStruct()
{
AugSettings ret = new AugSettings();
ret.loadPath = (string) m_loadPath_hand.Target;
return ret;
}
#region IDisposable Members
~AugSettings_Wrapper()
{
Dispose();
}
bool disposed = false;
public void Dispose()
{
lock (this)
{
if (!disposed)
{
m_loadPath_hand.Free();
disposed = true;
}
}
}
#endregion
}