public CloudflareService(ILogger <CloudflareService> logger, IOptions <ProcessSettings> settings, IOptions <CloudflareSettings> cloudflareSettings, IEnumerable <DDNSSettings> ddnsConfig, IPersistenceService persistenceService) { _logger = logger; _settings = settings.Value; _cloudflareSettings = cloudflareSettings.Value; _dDNSSettings = ddnsConfig; _persistenceService = persistenceService; }
static async Task Main(string[] args) { // Grabs the appsetting config. IConfiguration configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables() .AddCommandLine(args) .Build(); // Binds the dynamic object to the settings model _settings = new CloudflareSettings(); configuration.Bind("Cloudflare", _settings); // Creates an instance of the CloudflareAPI object api = new CloudflareApi(_settings.ApiKey, _settings.UserEmail); // Creates a list of DNS Records records = new List <DnsRecordDetails>(); /// Loops through the records wanting to be watched and updated foreach (var record in _settings.Records) { records.Add(await api.GetRecordInfo(record.ZoneId, record.RecordId)); } // Starts a timer that goes off every 10 minutes to check for updates var timer = new System.Timers.Timer(10 * 1000); timer.Elapsed += new System.Timers.ElapsedEventHandler(timerPassed); timer.Start(); // Check for an update now await checkForUpdates(); Console.ReadLine(); }