Пример #1
0
        /// <summary>
        /// Create an instance of ConfigCatClient and setup AutoPoll mode
        /// </summary>
        /// <param name="configuration">Configuration for AutoPolling mode</param>
        /// <exception cref="ArgumentException">When the configuration contains any invalid property</exception>
        /// <exception cref="ArgumentNullException">When the configuration is null</exception>
        public ConfigCatClient(AutoPollConfiguration configuration)
            : this((ConfigurationBase)configuration)
        {
            var autoPollService = new AutoPollConfigService(
                new HttpConfigFetcher(configuration.CreateUri(), "a-" + version, configuration.Logger, configuration.HttpClientHandler, this.configDeserializer, configuration.IsCustomBaseUrl),
                this.cacheParameters,
                TimeSpan.FromSeconds(configuration.PollIntervalSeconds),
                TimeSpan.FromSeconds(configuration.MaxInitWaitTimeSeconds),
                configuration.Logger
                );

            autoPollService.OnConfigurationChanged += configuration.RaiseOnConfigurationChanged;

            this.configService = autoPollService;
        }
        /// <summary>
        /// Create an instance of ConfigCatClient and setup AutoPoll mode
        /// </summary>
        /// <param name="configuration">Configuration for AutoPolling mode</param>
        /// <exception cref="ArgumentException">When the configuration contains any invalid property</exception>
        /// <exception cref="ArgumentNullException">When the configuration is null</exception>
        public ConfigCatClient(AutoPollConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            configuration.Validate();

            InitializeClient(configuration);

            var configService = new AutoPollConfigService(
                new HttpConfigFetcher(configuration.Url, "a-" + version, configuration.LoggerFactory),
                new InMemoryConfigCache(),
                TimeSpan.FromSeconds(configuration.PollIntervalSeconds),
                TimeSpan.FromSeconds(configuration.MaxInitWaitTimeSeconds),
                configuration.LoggerFactory);

            configService.OnConfigurationChanged += configuration.RaiseOnConfigurationChanged;

            this.configService = configService;
        }