ClassSmartPasteButtonRequestContext
Provides data for the SmartPasteRequest event and the SmartPasteRequestCommand. Contains the clipboard content, fields, a cancellation token, and methods to signal the result of the AI request.
Definition
Namespace:Telerik.Maui.Controls.SmartPasteButton
Assembly:Telerik.Maui.Controls.dll
Syntax:
public class SmartPasteButtonRequestContext
Inheritance: objectSmartPasteButtonRequestContext
Properties
CancellationToken
Gets the cancellation token that is triggered when the user cancels the smart paste operation. Pass this token to async operations (e.g., HTTP requests) to support cooperative cancellation.
Declaration
public CancellationToken CancellationToken { get; }
Property Value
Content
The content to be processed by the Smart Paste Button. When the event is triggered or the command is executed, this property contains the clipboard content of the user.
Declaration
public string Content { get; }
Property Value
Remarks
Security — Prompt Injection: This value is raw, untrusted clipboard text. Do not embed it directly into an AI prompt without sanitization or clear contextual separation (e.g., wrapping it in delimiters and instructing the model to treat it as data only). Failure to do so may allow maliciously crafted clipboard content to override the AI's instructions.
Fields
Array of fields that should be populated with the AI response using the content provided.
Declaration
public SmartPasteButtonField[] Fields { get; }
Property Value
Methods
Cancel()
Call this method to cancel the smart paste operation.
Declaration
public void Cancel()
SetError(Exception)
Call this method to signal that an error occurred during the AI request.
Declaration
public void SetError(Exception exception = null)
Parameters
exception
SetResponse(Dictionary<string, object>)
Call this method to provide the AI response as a dictionary of field values. The button will convert the values and populate the provider fields.
Declaration
public void SetResponse(Dictionary<string, object> fieldValues)
Parameters
fieldValues