コード例 #1
0
 public void Dispose()
 {
     Handler.Dispose();
     _server.Dispose();
     _testMongoDb.Dispose();
     SmtpServer.Dispose();
 }
コード例 #2
0
 public void Dispose()
 {
     // TODO: I don't like this, but in the time scope we need to put it off
     _connection?.StopAsync().Wait();
     _connection?.DisposeAsync().Wait();
     _httpMessageHandler?.Dispose();
 }
コード例 #3
0
 public AsyncClient(
     string auth,
     int timeout,
     ProductInfoHeaderValue userAgent,
     HttpMessageHandler httpMessageHandler = null
     )
 {
     _httpMessageHandler = httpMessageHandler ?? new HttpClientHandler();
     try
     {
         _httpClient = new HttpClient(_httpMessageHandler)
         {
             DefaultRequestHeaders =
             {
                 Authorization = new AuthenticationHeaderValue("Basic", auth),
                 Accept        = { new MediaTypeWithQualityHeaderValue("application/json") },
                 UserAgent     = { userAgent }
             },
             Timeout = TimeSpan.FromMilliseconds(timeout)
         };
     }
     catch
     {
         _httpClient?.Dispose();
         _httpMessageHandler.Dispose();
         throw;
     }
 }
コード例 #4
0
ファイル: FlurlClient.cs プロジェクト: kamalpp/Flurl
 /// <summary>
 /// Disposes the underlying HttpClient and HttpMessageHandler, setting both properties to null.
 /// This FlurlClient can still be reused, but those underlying objects will be re-created as needed. Previously set headers, etc, will be lost.
 /// </summary>
 public void Dispose()
 {
     _httpMessageHandler?.Dispose();
     _httpClient?.Dispose();
     _httpMessageHandler = null;
     _httpClient         = null;
 }
コード例 #5
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         _innerHandler.Dispose();
     }
 }
コード例 #6
0
ファイル: FlurlClient.cs プロジェクト: t13ka/Flurl
 /// <summary>
 /// Disposes the underlying HttpClient and HttpMessageHandler, setting both properties to null.
 /// This FlurlClient can still be reused, but those underlying objects will be re-created as needed. Previously set headers, etc, will be lost.
 /// </summary>
 public void Dispose()
 {
     _httpMessageHandler?.Dispose();
     _httpClient?.Dispose();
     _httpMessageHandler = null;
     _httpClient         = null;
     Cookies             = new Dictionary <string, Cookie>();
 }
コード例 #7
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _httpClient?.Dispose();
         _httpMessageHandler?.Dispose();
     }
 }
コード例 #8
0
        /// <summary>
        /// Implementation of the <see cref="IDisposable"/> pattern for derived classes to use
        /// </summary>
        /// <param name="disposing">True if calling from <see cref="Dispose()"/> or the finalizer.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                roothandler?.Dispose();
                roothandler = null;

                client?.Dispose();
                client = null;
            }
        }
コード例 #9
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting
        /// unmanaged resources.
        /// </summary>
        /// <remarks>
        /// Since this class is <see langword="sealed"/>, the standard <see
        /// cref="IDisposable.Dispose"/> pattern is not required. Also, <see
        /// cref="GC.SuppressFinalize"/> is not needed.
        /// </remarks>
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _handler?.Dispose();

            _disposed = true;
        }
コード例 #10
0
        private bool disposedValue; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    IsConnected = false;
                    messageHandler.Dispose();
                }

                disposedValue = true;
            }
        }
コード例 #11
0
        /// <summary>
        /// Disposes the current instance.
        /// </summary>
        /// <remarks>
        /// This will dispose the underlying <see cref="HttpClientHandler"/>,
        /// so it can only be called after it is no longer in use.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // TODO: This has high potential to cause coding defects. See if we can do better,
                    // perhaps do something like `Microsoft.Extensions.Http.LifetimeTrackingHttpMessageHandler`.
                    _handler.Dispose();
                }

                _disposed = true;
            }
        }
コード例 #12
0
        public void Dispose()
        {
            if (!string.IsNullOrEmpty(json))
            {
                json = null;
            }

            if (httpClient != null)
            {
                httpClient.Dispose();
                handler.Dispose();
                _serializer = null;
            }
        }
コード例 #13
0
        public void Dispose()
        {
            if (_messageHandler != null)
            {
                _messageHandler.Dispose();
                _messageHandler = null;
            }

            if (_httpClient != null)
            {
                _httpClient.Dispose();
                _httpClient = null;
            }
        }
コード例 #14
0
        protected virtual void Dispose(bool disposing)
        {
            if (Disposed)
            {
                return;
            }

            if (disposing)
            {
                LastHttpClient?.Dispose();
                _httpMessageHandler.Dispose();
            }

            Disposed = true;
        }
コード例 #15
0
        /// <summary>
        /// Dispose of the underlying HttpClient.
        /// </summary>
        /// <param name="disposing"></param>
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _httpClient.Dispose();
                _httpMessageHandler.Dispose();
            }

            _disposed = true;
        }
コード例 #16
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _httpClient.Dispose();
                _httpMessageHandler?.Dispose();
            }

            _disposed = true;
        }
コード例 #17
0
        private bool disposedValue; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            logger.Debug("Disposing SonarQubeService...");
            if (!disposedValue)
            {
                logger.Debug("SonarQubeService was not disposed, continuing with dispose...");
                if (disposing)
                {
                    IsConnected      = false;
                    SonarQubeVersion = null;
                    messageHandler.Dispose();
                }

                disposedValue = true;
            }
        }
コード例 #18
0
        public async Task Shutdown(bool keepDb = false)
        {
            StoppingTime.Start();

            _kestrelTestServer.Dispose();
            HttpMessageHandler.Dispose();
            HttpClient.Dispose();
            await Node.StopAsync().WithTimeout(TimeSpan.FromSeconds(20)).ConfigureAwait(false);

            if (!keepDb)
            {
                TryDeleteDirectory(DbPath);
            }

            StoppingTime.Stop();
            RunningTime.Stop();
        }
コード例 #19
0
        /// <summary>
        /// Releases all associated resources.
        /// </summary>
        /// <param name="disposing">Pass <c>true</c> if we're disposing, <c>false</c> if we're finalizing.</param>
        protected void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (client != null)
                {
                    client.Dispose();
                    client = null;
                }

                if (handler != null && disposeHandler)
                {
                    handler.Dispose();
                    handler = null;
                }
            }
        }
コード例 #20
0
ファイル: AdjustFactory.cs プロジェクト: ryihan/windows_sdk
        public static void Teardown()
        {
            _iPackageHandler     = null;
            _iRequestHandler     = null;
            _iAttributionHandler = null;
            _logger = null;
            _httpMessageHandler?.Dispose();
            _httpMessageHandler             = null;
            _packageHandlerBackoffStrategy  = null;
            _sdkClickHandlerBackoffStrategy = null;

            _timerInterval      = DefaultTimerInterval;
            _timerStart         = DefaultTimerStart;
            _sessionInterval    = DefaultSessionInterval;
            _subsessionInterval = DefaultSubsessionInterval;
            _maxDelayStart      = DefaultMaxDelayStart;
            _baseUrl            = Constants.BASE_URL;
        }
コード例 #21
0
ファイル: Client.cs プロジェクト: mParticle/consuldotnet
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    Config.Updated -= HandleConfigUpdateEvent;
                    if (HttpClient != null && !skipClientDispose)
                    {
                        HttpClient.Dispose();
                    }
                    if (Handler != null)
                    {
                        Handler.Dispose();
                    }
                }

                disposedValue = true;
            }
        }
コード例 #22
0
 /// <summary>
 /// Constructor for minFraud web service client.
 /// </summary>
 /// <param name="accountId">Your MaxMind account ID.</param>
 /// <param name="licenseKey">Your MaxMind license key.</param>
 /// <param name="locales">A list of locale codes to use for name property.</param>
 /// <param name="host">The host to use when connecting to the web service.</param>
 /// <param name="timeout">The timeout to use for the request.</param>
 /// <param name="httpMessageHandler">Handler to use in request. For unit testing only.</param>
 public WebServiceClient(
     int accountId,
     string licenseKey,
     IEnumerable <string>?locales = null,
     string host      = "minfraud.maxmind.com",
     TimeSpan?timeout = null,
     HttpMessageHandler?httpMessageHandler = null
     )
 {
     _locales = locales == null ? new List <string> {
         "en"
     } : new List <string>(locales);
     _httpMessageHandler = httpMessageHandler ?? new HttpClientHandler();
     try
     {
         _httpClient = new HttpClient(httpMessageHandler ?? new HttpClientHandler())
         {
             BaseAddress           = new UriBuilder("https", host, -1, BasePath).Uri,
             DefaultRequestHeaders =
             {
                 Authorization = new AuthenticationHeaderValue("Basic",
                                                               Convert.ToBase64String(
                                                                   Encoding.ASCII.GetBytes(
                                                                       $"{accountId}:{licenseKey}"))),
                 Accept    = { new MediaTypeWithQualityHeaderValue("application/json") },
                 UserAgent = { new ProductInfoHeaderValue("minFraud-api-dotnet", Version) }
             }
         };
         if (timeout != null)
         {
             _httpClient.Timeout = timeout.Value;
         }
     }
     catch
     {
         _httpClient?.Dispose();
         _httpMessageHandler.Dispose();
         throw;
     }
 }
コード例 #23
0
        /// <summary>
        /// Disposes the current instance.
        /// </summary>
        /// <remarks>
        /// This will dispose the underlying <see cref="HttpClientHandler"/>,
        /// so it can only be called after it is no longer in use.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // TODO: This has high potential to cause coding defects. See if we can do better,
                    // perhaps do something like `Microsoft.Extensions.Http.LifetimeTrackingHttpMessageHandler`.
                    _normalHandler.Dispose();

                    var currentUpgradableHandler = Volatile.Read(ref _upgradableHandler);
                    if (currentUpgradableHandler != null)
                    {
                        if (Interlocked.CompareExchange(ref _upgradableHandler, null, currentUpgradableHandler) == currentUpgradableHandler)
                        {
                        }
                    }
                }

                _disposed = true;
            }
        }
コード例 #24
0
ファイル: HttpClientService.cs プロジェクト: liuguiyou/FclEx
        protected override void SetProxy(IWebProxyExt proxy)
        {
            proxy = proxy ?? WebProxyExt.None;
            if (Equals(_webProxy, proxy))
            {
                return;
            }

            switch (proxy.Type)
            {
            case ProxyType.None:
            case ProxyType.Http:
            case ProxyType.Https:
            {
                _handler?.Dispose();
                _handler = CreateDefaultHandler(_webProxy);
                break;
            }

            case ProxyType.Socks5:
            {
                _handler?.Dispose();
                _handler = new ProxyClientHandler <Socks5>(new ProxySettings
                    {
                        Port        = proxy.Port,
                        Host        = proxy.Host,
                        Credentials = proxy.Credentials as NetworkCredential
                    });
                break;
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(proxy.Type), proxy.Type, null);
            }
            _webProxy = proxy;
            _httpClient?.Dispose();
            SetHttpClient();
        }
コード例 #25
0
 public void Dispose()
 {
     HttpClient?.Dispose();
     _httpMessageHandler?.Dispose();
 }
コード例 #26
0
ファイル: HttpClientService.cs プロジェクト: liuguiyou/FclEx
 public override void Dispose()
 {
     _handler.Dispose();
     _httpClient.Dispose();
 }
コード例 #27
0
 /// <inheritdoc />
 public void Dispose()
 {
     _handler.Dispose();
 }
コード例 #28
0
ファイル: SlackClient.cs プロジェクト: mykquayce/Helpers
 public void Dispose()
 {
     _httpClient?.Dispose();
     _handler?.Dispose();
 }
コード例 #29
0
 public void Dispose()
 {
     _handler?.Dispose();
     _host?.Dispose();
     _server?.Dispose();
 }
コード例 #30
0
 public void Dispose()
 {
     _messageHandler.Dispose();
 }