Files

123 lines
2.9 KiB
C#

// <auto-generated/> by Diplomat
#pragma warning disable 0105
using System;
using System.Runtime.InteropServices;
using Devolutions.IronRdp.Diplomat;
#pragma warning restore 0105
namespace Devolutions.IronRdp;
#nullable enable
public partial class DynState: IDisposable
{
private unsafe Raw.DynState* _inner;
public string Name
{
get
{
return GetName();
}
}
/// <summary>
/// Creates a managed <c>DynState</c> from a raw handle.
/// </summary>
/// <remarks>
/// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free).
/// <br/>
/// This constructor assumes the raw struct is allocated on Rust side.
/// If implemented, the custom Drop implementation on Rust side WILL run on destruction.
/// </remarks>
public unsafe DynState(Raw.DynState* handle)
{
_inner = handle;
}
/// <exception cref="IronRdpException"></exception>
public void GetName(DiplomatWriteable writeable)
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DynState");
}
Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.DynState.GetName(_inner, &writeable);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
}
}
/// <exception cref="IronRdpException"></exception>
public string GetName()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DynState");
}
DiplomatWriteable writeable = new DiplomatWriteable();
Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.DynState.GetName(_inner, &writeable);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
string retVal = writeable.ToUnicode();
writeable.Dispose();
return retVal;
}
}
public bool IsTerminal()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DynState");
}
bool retVal = Raw.DynState.IsTerminal(_inner);
return retVal;
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.DynState* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.DynState.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~DynState()
{
Dispose();
}
}