using Avalonia.Input.Platform;
namespace JdeScoping.SecureStoreManager.Services;
///
/// Avalonia implementation of IClipboardService.
///
public class AvaloniaClipboardService : IClipboardService
{
private readonly Func _getClipboard;
///
/// Creates a new instance of AvaloniaClipboardService.
///
/// Factory function to get the clipboard instance.
public AvaloniaClipboardService(Func getClipboard)
{
_getClipboard = getClipboard ?? throw new ArgumentNullException(nameof(getClipboard));
}
///
/// Sets the clipboard text asynchronously.
///
/// The text to set on the clipboard.
public async Task SetTextAsync(string text)
{
var clipboard = _getClipboard();
if (clipboard != null)
{
await clipboard.SetTextAsync(text);
}
}
}