public CosmosDBConfigurationSource(WebHostBuilderContext context, CosmosDBConfiguration configuration) { _context = context ?? throw new ArgumentNullException(nameof(context)); _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _watcherClient = new CosmosDBWatcherClient(_context, _configuration); _parser = new JsonParser(); }
public void Dispose() { _watcherClient.Dispose(); _watcherClient = null; _parser = null; }
public CosmosDBConfigurationProvider(WebHostBuilderContext context, CosmosDBConfiguration configuration, IWatcherClient watcherClient, IParser <string> parser) { _context = context ?? throw new ArgumentNullException(nameof(context)); _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _parser = parser ?? throw new ArgumentNullException(nameof(parser)); if (watcherClient == null) { throw new ArgumentNullException(nameof(watcherClient)); } if (string.IsNullOrWhiteSpace(configuration.ConnectionString)) { throw new ArgumentNullException(nameof(configuration), "Connectionstring is missing from configuration"); } if (string.IsNullOrWhiteSpace(configuration.Database)) { throw new ArgumentNullException(nameof(configuration), "Database is missing from configuration"); } if (string.IsNullOrWhiteSpace(configuration.PrimaryKey)) { throw new ArgumentNullException(nameof(configuration), "Primary key is missing from configuration"); } if (_configuration.ReloadOnChange) { _changeTokenRegistration = ChangeToken.OnChange(watcherClient.Watch, LoadSettings); } }