예제 #1
0
        /// <summary>
        /// Gets a connection string for these credentials.
        /// </summary>
        /// <returns>Connection string for this credentials set.</returns>
        public async Task <string> GetConnectionStringAsync()
        {
            if (_credentials.IsExpired)
            {
                try
                {
                    await _semaphore.WaitAsync();

                    if (_credentials.IsExpired)
                    {
                        var credentials = await _refreshCredentials();

                        _connectionString = _createConnectionString(_connectionString, credentials);
                        _credentials      = credentials;
                    }
                }
                finally
                {
                    _semaphore.Release();
                }
            }

            return(_connectionString);
        }
예제 #2
0
 /// <summary>
 /// Produces a connection string using the new credentials.
 /// </summary>
 /// <param name="connectionString">The original connection string.</param>
 /// <param name="credentials">The new credentials to use.</param>
 /// <returns>
 /// A new connection string.
 /// </returns>
 protected abstract string WithNewCredentials(string connectionString, ExpiringCredentials credentials);