// 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 ClipboardMessage: IDisposable { private unsafe Raw.ClipboardMessage* _inner; public ClipboardMessageType MessageType { get { return GetMessageType(); } } public FormatDataResponse? SendFormatData { get { return GetSendFormatData(); } } public ClipboardFormatIterator? SendInitiateCopy { get { return GetSendInitiateCopy(); } } public ClipboardFormatId? SendInitiatePaste { get { return GetSendInitiatePaste(); } } /// /// Creates a managed ClipboardMessage from a raw handle. /// /// /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
public unsafe ClipboardMessage(Raw.ClipboardMessage* handle) { _inner = handle; } /// /// A ClipboardMessageType allocated on C# side. /// public ClipboardMessageType GetMessageType() { unsafe { if (_inner == null) { throw new ObjectDisposedException("ClipboardMessage"); } Raw.ClipboardMessageType retVal = Raw.ClipboardMessage.GetMessageType(_inner); return (ClipboardMessageType)retVal; } } /// /// A ClipboardFormatIterator allocated on Rust side. /// public ClipboardFormatIterator? GetSendInitiateCopy() { unsafe { if (_inner == null) { throw new ObjectDisposedException("ClipboardMessage"); } Raw.ClipboardFormatIterator* retVal = Raw.ClipboardMessage.GetSendInitiateCopy(_inner); if (retVal == null) { return null; } return new ClipboardFormatIterator(retVal); } } /// /// A FormatDataResponse allocated on Rust side. /// public FormatDataResponse? GetSendFormatData() { unsafe { if (_inner == null) { throw new ObjectDisposedException("ClipboardMessage"); } Raw.FormatDataResponse* retVal = Raw.ClipboardMessage.GetSendFormatData(_inner); if (retVal == null) { return null; } return new FormatDataResponse(retVal); } } /// /// A ClipboardFormatId allocated on Rust side. /// public ClipboardFormatId? GetSendInitiatePaste() { unsafe { if (_inner == null) { throw new ObjectDisposedException("ClipboardMessage"); } Raw.ClipboardFormatId* retVal = Raw.ClipboardMessage.GetSendInitiatePaste(_inner); if (retVal == null) { return null; } return new ClipboardFormatId(retVal); } } /// /// Returns the underlying raw handle. /// public unsafe Raw.ClipboardMessage* AsFFI() { return _inner; } /// /// Destroys the underlying object immediately. /// public void Dispose() { unsafe { if (_inner == null) { return; } Raw.ClipboardMessage.Destroy(_inner); _inner = null; GC.SuppressFinalize(this); } } ~ClipboardMessage() { Dispose(); } }