public HttpDownloadManager(int requestDelay = DefaultRequestDelay, int fileRequestDelay = DefaultFileRequestDelay,
         int retryAttempts = DefaultRetryAttempts, ProxyBase proxy = null)
      {
         _requestDelay = requestDelay;
         _fileRequestDelay = fileRequestDelay;
         _retryAttempts = retryAttempts;

         _proxy = proxy ?? DefaultProxy;
      }
        public HttpDownloadManager(int requestDelay  = DefaultRequestDelay, int fileRequestDelay = DefaultFileRequestDelay,
                                   int retryAttempts = DefaultRetryAttempts, ProxyBase proxy     = null)
        {
            _requestDelay     = requestDelay;
            _fileRequestDelay = fileRequestDelay;
            _retryAttempts    = retryAttempts;

            _proxy = proxy ?? DefaultProxy;
        }
        internal HttpDownloadManager(IActivatorProxy activatorProxy)
        {
            if (activatorProxy == null)
            {
                throw new ArgumentNullException("activatorProxy");
            }

            var requestDelaySetting = ConfigurationManager.AppSettings["TM.HttpDownloadManager.RequestDelay"];

            if (requestDelaySetting == null)
            {
                _requestDelay = DefaultRequestDelay;
            }

            _requestDelay = Convert.ToInt32(requestDelaySetting);


            var fileRequestDelaySetting = ConfigurationManager.AppSettings["TM.HttpDownloadManager.FileRequestDelay"];

            if (fileRequestDelaySetting == null)
            {
                _fileRequestDelay = DefaultFileRequestDelay;
            }

            _fileRequestDelay = Convert.ToInt32(fileRequestDelaySetting);

            var retryAttemptsSetting = ConfigurationManager.AppSettings["TM.HttpDownloadManager.RetryAttempts"];

            if (retryAttemptsSetting == null)
            {
                _retryAttempts = DefaultRetryAttempts;
            }

            _retryAttempts = Convert.ToInt32(retryAttemptsSetting);

            var proxyTypeSetting = ConfigurationManager.AppSettings["TM.HttpDownloadManager.ProxyType"];

            if (proxyTypeSetting == null)
            {
                _proxy = DefaultProxy;
            }
            else
            {
                _proxy = activatorProxy.CreateInstance <ProxyBase>(proxyTypeSetting);
            }
        }
        public void Dispose()
        {
            if (!_disposed)
            {
                if (_httpClient != null)
                {
                    _httpClient.Dispose();
                    _httpClient = null;
                }

                if (_proxy != null)
                {
                    _proxy.Dispose();
                    _proxy = null;
                }

                _disposed = true;
            }
        }
      internal HttpDownloadManager(IActivatorProxy activatorProxy)
      {
         if (activatorProxy == null)
            throw new ArgumentNullException("activatorProxy");

         var requestDelaySetting = ConfigurationManager.AppSettings["TM.HttpDownloadManager.RequestDelay"];
         if (requestDelaySetting == null)
         {
            _requestDelay = DefaultRequestDelay;
         }

         _requestDelay = Convert.ToInt32(requestDelaySetting);


         var fileRequestDelaySetting = ConfigurationManager.AppSettings["TM.HttpDownloadManager.FileRequestDelay"];
         if (fileRequestDelaySetting == null)
         {
            _fileRequestDelay = DefaultFileRequestDelay;
         }

         _fileRequestDelay = Convert.ToInt32(fileRequestDelaySetting);

         var retryAttemptsSetting = ConfigurationManager.AppSettings["TM.HttpDownloadManager.RetryAttempts"];
         if (retryAttemptsSetting == null)
         {
            _retryAttempts = DefaultRetryAttempts;
         }

         _retryAttempts = Convert.ToInt32(retryAttemptsSetting);

         var proxyTypeSetting = ConfigurationManager.AppSettings["TM.HttpDownloadManager.ProxyType"];
         if (proxyTypeSetting == null)
         {
            _proxy = DefaultProxy;
         } else
         {
            _proxy = activatorProxy.CreateInstance<ProxyBase>(proxyTypeSetting);
         }

      }
      public void Dispose()
      {
         if (!_disposed)
         {
            if (_httpClient != null)
            {
               _httpClient.Dispose();
               _httpClient = null;
            }

            if (_proxy != null)
            {
               _proxy.Dispose();
               _proxy = null;
            }

            _disposed = true;
         }
      }