protected override void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    if (_credentials != null)
                    {
                        _credentials.Dispose();
                        _credentials = null;
                    }
                }

                _disposed = true;
            }
        }
 /// <summary>
 /// Constructs a BasicCSCredentials object for the specified accessKey and secretKey
 /// SecretKey is stored in SecureString
 /// </summary>
 /// <param name="accessKey"></param>
 /// <param name="secretKey"></param>
 public BasicCSCredentials(string accessKey, SecureString secretKey)
 {
     _credentials = new ImmutableCredentials(accessKey, secretKey, null);
 }
 /// <summary>
 /// Returns a copy of the current credentials.
 /// </summary>
 /// <returns></returns>
 public ImmutableCredentials Copy()
 {
     ImmutableCredentials credentials = new ImmutableCredentials
     {
         AccessKey = this.AccessKey,
         ClearSecretKey = this.ClearSecretKey,
         SecureSecretKey = (this.SecureSecretKey == null ? null : this.SecureSecretKey.Copy()),
     };
     return credentials;
 }
 /// <summary>
 /// Constructs a BasicCSCredentials object for the specified accessKey and secretKey,
 /// with the useSecureString flag to signal if the secretKey should be stored as SecureString
 /// </summary>
 /// <param name="accessKey"></param>
 /// <param name="secretKey"></param>
 /// <param name="useSecureString">
 /// True if secretKey should be stored in SecureString. False if secretKey should be stored as clear string.
 /// </param>
 public BasicCSCredentials(string accessKey, string secretKey, bool useSecureString)
 {
     _credentials = new ImmutableCredentials(accessKey, secretKey, null, useSecureString);
 }
        /// <summary>
        /// Constructs an instance of EnvironmentCSCredentials and attempts
        /// to load AccessKey and SecretKey from ConfigurationManager.AppSettings
        /// </summary>
        public EnvironmentCSCredentials()
        {
            //NameValueCollection appConfig = ConfigurationManager.AppSettings;
            NameValueCollection appConfig = null;
            var accessKey = appConfig[ACCESSKEY];
            var secretKey = appConfig[SECRETKEY];

            if (string.IsNullOrEmpty(accessKey))
                throw new ArgumentException(string.Format("Access Key could not be found.  Add an appsetting to your App.config with the name {0} with a value of your access key.", ACCESSKEY));
            if (string.IsNullOrEmpty(secretKey))
                throw new ArgumentException(string.Format("Secret Key could not be found.  Add an appsetting to your App.config with the name {0} with a value of your secret key.", SECRETKEY));

            this._wrappedCredentials = new ImmutableCredentials(accessKey, secretKey, null, false);
        }