Beispiel #1
0
        private Connection GetConnection(CosmosDbServiceInfo info, IConfiguration configuration)
        {
            var cosmosConfig = new CosmosDbConnectorOptions(configuration);
            var configurer   = new CosmosDbProviderConfigurer();
            var conn         = new Connection(configurer.Configure(info, cosmosConfig), "CosmosDb", info);

            conn.Properties.Add("DatabaseId", cosmosConfig.DatabaseId);
            conn.Properties.Add("DatabaseLink", cosmosConfig.DatabaseLink);

            return(conn);
        }
Beispiel #2
0
        public Connection Get(IConfiguration configuration, string serviceName)
        {
            var info = serviceName == null
               ? configuration.GetSingletonServiceInfo <CosmosDbServiceInfo>()
               : configuration.GetRequiredServiceInfo <CosmosDbServiceInfo>(serviceName);

            var cosmosConfig = new CosmosDbConnectorOptions(configuration)
            {
                UseReadOnlyCredentials = true
            };

            var configurer = new CosmosDbProviderConfigurer();

            return(new Connection
            {
                ConnectionString = configurer.Configure(info, cosmosConfig),
                Name = "CosmosDbReadOnly" + serviceName?.Insert(0, "-")
            });
        }
Beispiel #3
0
        public Connection Get(IConfiguration configuration, string serviceName)
        {
            var info = serviceName == null
               ? configuration.GetSingletonServiceInfo <CosmosDbServiceInfo>()
               : configuration.GetRequiredServiceInfo <CosmosDbServiceInfo>(serviceName);

            var cosmosConfig = new CosmosDbConnectorOptions(configuration);
            var configurer   = new CosmosDbProviderConfigurer();
            var conn         = new Connection
            {
                ConnectionString = configurer.Configure(info, cosmosConfig),
                Name             = "CosmosDb" + serviceName?.Insert(0, "-")
            };

            conn.Properties.Add("DatabaseId", cosmosConfig.DatabaseId);
            conn.Properties.Add("DatabaseLink", cosmosConfig.DatabaseLink);

            return(conn);
        }