mirror of
https://github.com/netbirdio/IronRDP.git
synced 2026-05-22 18:43:12 -07:00
114 lines
2.7 KiB
C#
114 lines
2.7 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 Char: IDisposable
|
|
{
|
|
private unsafe Raw.Char* _inner;
|
|
|
|
/// <summary>
|
|
/// Creates a managed <c>Char</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 Char(Raw.Char* handle)
|
|
{
|
|
_inner = handle;
|
|
}
|
|
|
|
/// <exception cref="IronRdpException"></exception>
|
|
/// <returns>
|
|
/// A <c>Char</c> allocated on Rust side.
|
|
/// </returns>
|
|
public static Char New(uint c)
|
|
{
|
|
unsafe
|
|
{
|
|
Raw.InputFfiResultBoxCharBoxIronRdpError result = Raw.Char.New(c);
|
|
if (!result.isOk)
|
|
{
|
|
throw new IronRdpException(new IronRdpError(result.Err));
|
|
}
|
|
Raw.Char* retVal = result.Ok;
|
|
return new Char(retVal);
|
|
}
|
|
}
|
|
|
|
/// <returns>
|
|
/// A <c>Operation</c> allocated on Rust side.
|
|
/// </returns>
|
|
public Operation AsOperationUnicodeKeyPressed()
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
throw new ObjectDisposedException("Char");
|
|
}
|
|
Raw.Operation* retVal = Raw.Char.AsOperationUnicodeKeyPressed(_inner);
|
|
return new Operation(retVal);
|
|
}
|
|
}
|
|
|
|
/// <returns>
|
|
/// A <c>Operation</c> allocated on Rust side.
|
|
/// </returns>
|
|
public Operation AsOperationUnicodeKeyReleased()
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
throw new ObjectDisposedException("Char");
|
|
}
|
|
Raw.Operation* retVal = Raw.Char.AsOperationUnicodeKeyReleased(_inner);
|
|
return new Operation(retVal);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the underlying raw handle.
|
|
/// </summary>
|
|
public unsafe Raw.Char* AsFFI()
|
|
{
|
|
return _inner;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Destroys the underlying object immediately.
|
|
/// </summary>
|
|
public void Dispose()
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Raw.Char.Destroy(_inner);
|
|
_inner = null;
|
|
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|
|
|
|
~Char()
|
|
{
|
|
Dispose();
|
|
}
|
|
}
|