Interface IDataTypeDetector
Represents a way to detect the type of data coming from an external source such as the OS's clipboard.
Namespace: DevToys.Api
Assembly: DevToys.Api.dll
Syntax
public interface IDataTypeDetector
Remarks
[Export(typeof(IDataTypeDetector))]
[DataTypeName("jwt-header", baseName: "json" /* optional */)] // jwt-header type inheriting from json type.
[TargetPlatform(Platform.Windows)] // Optional
[TargetPlatform(Platform.WASM)] // Optional
internal sealed class JwtDetector : IDataTypeDetector
{
}
Methods
TryDetectDataAsync(object, DataDetectionResult?, CancellationToken)
Tries to detect whether the given rawData
match the expected format known by this
IDataTypeDetector, often by trying to reading and/or parsing it.
Declaration
ValueTask<DataDetectionResult> TryDetectDataAsync(object rawData, DataDetectionResult? resultFromBaseDetector, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
object | rawData | The data to analyze, often coming from the OS's clipboard. |
DataDetectionResult | resultFromBaseDetector | The result coming from the IDataTypeDetector corresponding to the given DataTypeBaseName. Since, the DataTypeBaseName is optional, this parameter can be null. |
CancellationToken | cancellationToken | A CancellationToken that gets canceled within 2 seconds. |
Returns
Type | Description |
---|---|
ValueTask<DataDetectionResult> | Returns a DataDetectionResult that indicates whether the data could be analyzed / parsed / read correctly, along with the parsed data, if any change has been made to it during parsing (for example, string to integer conversion). |
Remarks
When the data successfully got parsed, pass the parsed value to Data.
Ultimately, when detection is successful, the Data will be passed to OnDataReceived(string, object?).