Documentation Index
Fetch the complete documentation index at: https://mintlify.com/DevToys-app/DevToys/llms.txt
Use this file to discover all available pages before exploring further.
IDataTypeDetector is the interface at the heart of DevToys Smart Detection. When the user copies something to the clipboard, DevToys runs every registered detector in dependency order and routes the detected type to any IGuiTool that declared [AcceptedDataTypeName] for that type. Implement this interface to teach DevToys how to recognize a new data format — whether that’s a JWT token, a color hex string, a URL, or anything else — and optionally parse the raw input into a typed value that gets forwarded to your tool.
Namespace: DevToys.Api
Interface Declaration
Members
TryDetectDataAsync(object rawData, DataDetectionResult? resultFromBaseDetector, CancellationToken cancellationToken)
ValueTask<DataDetectionResult>
Tries to detect whether
rawData matches the format this detector understands. Return DataDetectionResult.Unsuccessful if the data does not match, or a successful DataDetectionResult carrying an optional parsed value if it does.| Parameter | Type | Description |
|---|---|---|
rawData | object | The data to analyze, typically a string coming from the OS clipboard. |
resultFromBaseDetector | DataDetectionResult? | The result returned by the parent detector declared in [DataTypeName(baseName: "...")]. null when no base type was declared. Use resultFromBaseDetector.Data to access the already-parsed value from the parent stage. |
cancellationToken | CancellationToken | Canceled within 2 seconds. Detection must be fast — do not perform network I/O or heavy computation inside this method. |
DataDetectionResult
DataDetectionResult is a record that carries the outcome of your detection attempt.
Factory Usage
| Expression | When to use |
|---|---|
DataDetectionResult.Unsuccessful | The data does not match your format — return this static field. |
new DataDetectionResult(true, parsedValue) | Detection succeeded; pass the strongly-typed parsed object as Data. This value is later forwarded to IGuiTool.OnDataReceived as parsedData. |
Detector Inheritance with baseName
The [DataTypeName] attribute accepts an optional baseName parameter that creates a parent–child relationship between detectors. The child detector runs after the parent and receives the parent’s DataDetectionResult as resultFromBaseDetector. This lets you layer refinements on top of a more general detector without duplicating logic.
resultFromBaseDetector.Data, so you only need to check whether the JSON has the fields of a JWT header — no raw text parsing required.
Full Example
Wiring to a GUI Tool
Once your detector is registered, annotate yourIGuiTool implementation so DevToys routes detected data to it: