Megosztás a következőn keresztül:


DigitalTwinsClient.GetComponentAsync<T> Method

Definition

Gets a component on a digital twin asynchronously.

public virtual System.Threading.Tasks.Task<Azure.Response<T>> GetComponentAsync<T> (string digitalTwinId, string componentName, System.Threading.CancellationToken cancellationToken = default);
abstract member GetComponentAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<'T>>
override this.GetComponentAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<'T>>
Public Overridable Function GetComponentAsync(Of T) (digitalTwinId As String, componentName As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of T))

Type Parameters

T

The type to deserialize the component to.

Parameters

digitalTwinId
String

The Id of the digital twin.

componentName
String

The component being retrieved.

cancellationToken
CancellationToken

The cancellation token.

Returns

The deserialized object representation of the component corresponding to the provided componentName and the HTTP response Response<T>.

Exceptions

The exception that captures the errors from the service. Check the ErrorCode and Status properties for more details.

The exception is thrown when digitalTwinId or componentName is null.

Examples

await client.GetComponentAsync<MyCustomComponent>(basicDtId, SamplesConstants.ComponentName);
Console.WriteLine($"Retrieved component for digital twin '{basicDtId}'.");

Remarks

For more samples, see our repo samples.

Applies to

See also