Exemple #1
0
        public static IConfigurationBuilder AddCosmosDB(
            this IConfigurationBuilder configurationBuilder,
            Action <CosmosDBClientSettings, IConfiguration> setterFn)
        {
            var settings = new CosmosDBClientSettings();

            setterFn.Invoke(settings, configurationBuilder.Build());

            return(configurationBuilder.AddCosmosDB(settings));
        }
        public static IConfigurationBuilder AddCosmosDB(this IConfigurationBuilder configurationBuilder, Microsoft.AspNetCore.Hosting.IHostingEnvironment environment)
        {
            if (configurationBuilder == null)
            {
                throw new ArgumentNullException(nameof(configurationBuilder));
            }

            if (environment == null)
            {
                throw new ArgumentNullException(nameof(environment));
            }

            var settings = new CosmosDBClientSettings()
            {
                DatabaseName   = environment.ApplicationName,
                CollectionName = environment.EnvironmentName
            };

            return(configurationBuilder.AddCosmosDB(settings));
        }