次の方法で共有


DigitalTwinsClient.GetComponentAsync<T> メソッド

定義

デジタル ツインのコンポーネントを非同期的に取得します。

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))

型パラメーター

T

コンポーネントを逆シリアル化する型。

パラメーター

digitalTwinId
String

デジタル ツインの ID。

componentName
String

取得するコンポーネント。

cancellationToken
CancellationToken

キャンセル トークン。

戻り値

指定された componentName と HTTP 応答 Response<T>に対応するコンポーネントの逆シリアル化されたオブジェクト表現。

例外

サービスからのエラーをキャプチャする例外。 詳細については、 ErrorCode プロパティと Status プロパティを確認してください。

または componentName が の場合digitalTwinId、例外がnullスローされます。

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

注釈

その他のサンプルについては、 リポジトリのサンプルを参照してください。

適用対象

こちらもご覧ください