예제 #1
0
        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);
        }
예제 #2
0
        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.");
            }
        }