示例#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);
        }
示例#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, "-")
            });
        }
示例#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);
        }
 public virtual string CreateConnectionString()
 {
     return(_configurer.Configure(_info, _config));
 }