/// <summary> /// Creates a new provider with the related configuration. /// </summary> /// <param name="config"></param> internal ProviderBase(Configurations.DataTarget config, LoggerBase logger) { _logger = logger; _logger.Log(config.Name, LoggerPriorities.Verbose, "Initializing"); _config = config; }
internal ProviderFtp(Configurations.DataTarget config, LoggerBase logger) : base(config, logger) { _connection = new Configuration(config.Target); // add path to host and ensure a trailing / _host = _connection.GetValue <string>("host"); if (!_host.EndsWith("/")) { _host += "/"; } var path = _connection.GetValue <string>("path"); if (path != null) { _host += path; if (!_host.EndsWith("/")) { _host += "/"; } } }
internal ProviderDropbox(Configurations.DataTarget config, LoggerBase logger) : base(config, logger) { // parse config // we assume the target is the token var token = _config.Target; // check for optional path var args = token.Split(';'); foreach (var arg in args) { var keyValue = arg.Split('='); if (keyValue.Length == 2) { switch (keyValue[0].Trim().ToLower()) { case "token": token = keyValue[1].Trim(); break; case "path": _path = keyValue[1].Trim(); break; } } } if (string.IsNullOrEmpty(token)) { _logger.Log(_config.Name, LoggerPriorities.Error, "Token is missing."); return; } // format path if (_path == null) { _path = string.Empty; } if (!_path.StartsWith("/")) { _path = "/" + _path; } if (!_path.EndsWith("/")) { _path += "/"; } // init client DropboxCertHelper.InitializeCertPinning(); _requestHandler = new WebRequestHandler { ReadWriteTimeout = 10 * 1000 }; // Specify socket level timeout which decides maximum waiting time when no bytes are // received by the socket. _httpClient = new HttpClient(_requestHandler) { // Specify request level timeout which decides maximum time that can be spent on // download/upload files. Timeout = TimeSpan.FromMinutes(20) }; var clientConfig = new DropboxClientConfig(_config.Name) { HttpClient = _httpClient }; _client = new DropboxClient(token, clientConfig); }
internal ProviderDirectory(Configurations.DataTarget config, LoggerBase logger) : base(config, logger) { }