Ejemplo n.º 1
0
        private DigitalTwinClient(Uri uri, IotServiceClientCredentials credentials, params DelegatingHandler[] handlers)
        {
            var httpMessageHandler = HttpClientHelper.CreateDefaultHttpMessageHandler(null, uri, ServicePointHelpers.DefaultConnectionLeaseTimeout);

#pragma warning disable CA2000 // Dispose objects before losing scope (httpMessageHandlerWithDelegatingHandlers is disposed when the http client owning it is disposed)
            HttpMessageHandler httpMessageHandlerWithDelegatingHandlers = CreateHttpHandlerPipeline(httpMessageHandler, handlers);
#pragma warning restore CA2000 // Dispose objects before losing scope

#pragma warning disable CA2000 // Dispose objects before losing scope (httpClient is disposed when the protocol layer client owning it is disposed)
            var httpClient = new HttpClient(httpMessageHandlerWithDelegatingHandlers, true)
            {
                BaseAddress = uri
            };
#pragma warning restore CA2000 // Dispose objects before losing scope

#pragma warning restore CA2000 // Dispose objects before losing scope

            // When this client is disposed, all the http message handlers and delegating handlers will be disposed automatically
            _client         = new IotHubGatewayServiceAPIs(credentials, httpClient, true);
            _client.BaseUri = uri;
            _protocolLayer  = new DigitalTwin(_client);
        }
Ejemplo n.º 2
0
 private DigitalTwinClient(Uri uri, IotServiceClientCredentials credentials, params DelegatingHandler[] handlers)
 {
     _client        = new IotHubGatewayServiceAPIs(uri, credentials, handlers);
     _protocolLayer = new DigitalTwin(_client);
 }