/// <summary> /// Creates a new privider. /// </summary> /// <param name="config">The configuration for this provider.</param> /// <param name="target">The DataTarget this strategy will handle-</param> public ProviderBase(Configurations.DataStrategy config, DataTargets.ProviderBase target, LoggerBase logger) { _config = config; _target = target; _logger = logger; _timestamp = DateTime.UtcNow; }
/// <summary> /// Gets all targets with theire strategy from the configuration. /// </summary> /// <returns></returns> private List <DataStrategies.ProviderBase> GetTargets() { var targets = new List <DataStrategies.ProviderBase>(); foreach (Configurations.DataTarget dataTarget in Configurations.DataTargetsSection.GetDataTargets()) { // get target provider first if (string.IsNullOrEmpty(dataTarget.Provider)) { _logger.Log(_loggerTag, LoggerPriorities.Error, "Ignoring DataTarget without provider."); continue; } DataTargets.ProviderBase target = null; switch (dataTarget.Provider.ToLower().Trim()) { case "directory": target = new DataTargets.ProviderDirectory(dataTarget, _logger); break; case "dropbox": target = new DataTargets.ProviderDropbox(dataTarget, _logger); break; case "ftp": target = new DataTargets.ProviderFtp(dataTarget, _logger); break; } if (target == null) { _logger.Log(_loggerTag, LoggerPriorities.Error, "Unknown DataTarget {0}", dataTarget.Provider); continue; } if (dataTarget.Strategy == null) { continue; } if (string.IsNullOrEmpty(dataTarget.Strategy.Provider)) { _logger.Log(_loggerTag, LoggerPriorities.Error, "Ignoring strategy without provider."); continue; } // get strategy second DataStrategies.ProviderBase strategy = null; switch (dataTarget.Strategy.Provider.ToLower().Trim()) { case "days": strategy = new DataStrategies.ProviderDays(dataTarget.Strategy, target, _logger); break; case "generations": strategy = new DataStrategies.ProviderGenerations(dataTarget.Strategy, target, _logger); break; } if (strategy == null) { _logger.Log(_loggerTag, LoggerPriorities.Error, "Unknown strategry {0}", dataTarget.Strategy.Provider); continue; } targets.Add(strategy); } return(targets); }
public ProviderBase(DataStrategy config, DataTargets.ProviderBase target) { this.config = config; this.target = target; }