public DnsService(ILogger <DnsService> logger, IConfiguration configuration, IServiceScopeFactory scopeFactory) { Logger = logger; ScopeFactory = scopeFactory; using var scope = scopeFactory.CreateScope(); Options = configuration.GetSection("Host").Get <DnsHostOptions>(); EnsureOptionsSet(Options); }
private static void EnsureOptionsSet(DnsHostOptions options) { if (options == null) { throw new InvalidOperationException("No options provided."); } if (options.CheckIntervalMs < 1000) { throw new InvalidOperationException($"{nameof(DnsHostOptions.CheckIntervalMs)} must be >= 1000."); } }