当前位置: 首页>>代码示例>>C#>>正文


C# IConnectionPool类代码示例

本文整理汇总了C#中IConnectionPool的典型用法代码示例。如果您正苦于以下问题:C# IConnectionPool类的具体用法?C# IConnectionPool怎么用?C# IConnectionPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IConnectionPool类属于命名空间,在下文中一共展示了IConnectionPool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateConnection

	{
		public override IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error)
		{
			SqlConnectionStringBuilder builder = null;
			try {	
				if (settings.UseConnectionString) {
					builder = new SqlConnectionStringBuilder (settings.ConnectionString);
				} else {
					builder = new SqlConnectionStringBuilder ();
					builder.InitialCatalog = settings.Database;
					builder.UserID = settings.Username;
					builder.Password = settings.Password;
					builder.DataSource = String.Concat (settings.Server, ",", settings.Port);
					//builder.NetworkLibrary = "DBMSSOCN";
				}
				builder.Pooling = false;
				SqlConnection connection = new SqlConnection (builder.ToString ());
				connection.Open ();
				
				error = null;
				return new SqlServerPooledDbConnection (pool, connection);
			} catch (Exception e) {
				error = e.Message;
				return null;
			}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:25,代码来源:SqlServerConnectionProvider.cs

示例2: CreateConnection

	{
		public override IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error)
		{
			string connStr = null;
			try {	
				if (settings.UseConnectionString) {
					connStr = settings.ConnectionString;
				} else {
					//User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;
					if (settings.Port > 0)
						connStr = String.Format ("User ID={0};Password={1};Host={2};Port={3};Database={4};",
							settings.Username, settings.Password, settings.Server, settings.Port, settings.Database);
					else
						connStr = String.Format ("User ID={0};Password={1};Host={2};Database={3};",
							settings.Username, settings.Password, settings.Server, settings.Database);
						
				}
				connStr = SetConnectionStringParameter (connStr, String.Empty, "Pooling", "false");
				NpgsqlConnection connection = new NpgsqlConnection (connStr);
				connection.Open ();
				
				error = null;
				return new NpgsqlPooledDbConnection (pool, connection);
			} catch (Exception e) {
				error = e.Message;
				return null;
			}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:27,代码来源:NpgsqlConnectionProvider.cs

示例3: SealedVirtualCluster

		public SealedVirtualCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider)
		{
			this._cluster = cluster;
			this._connectionPool = pool;
			this._connection = new VirtualClusterConnection(cluster, dateTimeProvider);
			this._dateTimeProvider = dateTimeProvider;
		}
开发者ID:RossLieberman,项目名称:NEST,代码行数:7,代码来源:SealedVirtualCluster.cs

示例4: AbstractSchemaProvider

		protected AbstractSchemaProvider (IConnectionPool connectionPool)
		{
			if (connectionPool == null)
				throw new ArgumentNullException ("connectionPool");
			
			this.connectionPool = connectionPool;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:7,代码来源:AbstractSchemaProvider.cs

示例5: CreateConnection

        public override IPooledDbConnection CreateConnection(IConnectionPool pool, 
		                                                      DatabaseConnectionSettings settings, 
		                                                      out string error)
        {
            string connStr = null;
            try {
                if (settings.UseConnectionString) {
                    connStr = settings.ConnectionString;
                } else {
                    //"mongodb://[username:[email protected]]hostname[:port][/[database][?options]]"
                    //Default port is 27017.
                    if(!string.IsNullOrEmpty(settings.Username) && !string.IsNullOrEmpty(settings.Password)) {
                        connStr = String.Format("mongodb://{3}:{4}@{0}:{1}/{2}",
                        settings.Server, settings.Port, settings.Database, settings.Username, settings.Password);
                    } else {
                        connStr = String.Format("mongodb://{0}:{1}/{2}",
                        settings.Server, settings.Port, settings.Database);
                    }

                }
                MongoDbConnection connection = new MongoDbConnection(connStr, settings.Database);
                connection.Open();
                error = null;
                return new MongoDbPooledDbConnection (pool, connection);
            } catch (Exception e) {
                error = e.Message;
                return null;
            }
        }
开发者ID:schamane,项目名称:monodevelop-mongodb-provider,代码行数:29,代码来源:MongoDbConnectionProvider.cs

示例6: MongoDbSchemaProvider

 public MongoDbSchemaProvider(IConnectionPool connectionPool)
     : base(connectionPool)
 {
     AddSupportedSchemaActions (SchemaType.Database, SchemaActions.All);
     AddSupportedSchemaActions (SchemaType.Table, SchemaActions.Create | SchemaActions.Drop | SchemaActions.Rename | SchemaActions.Schema);
     AddSupportedSchemaActions (SchemaType.User, SchemaActions.None);
 }
开发者ID:schamane,项目名称:monodevelop-mongodb-provider,代码行数:7,代码来源:MongoDbSchemaProvider.cs

示例7: CreateConnection

	{
		public override IPooledDbConnection CreateConnection (IConnectionPool pool, 
		                                                      DatabaseConnectionSettings settings, 
		                                                      out string error)
		{
			string connStr = null;
			try {	
				if (settings.UseConnectionString) {
					connStr = settings.ConnectionString;
				} else {
					//"Server=Server;Port=1234;Database=Test;Uid=UserName;Pwd=asdasd;"
					//Default port is 3306. Enter value -1 to use a named pipe connection. 
					if (settings.Port > 0)
						connStr = String.Format ("Server={0};Port={1};Database={2};Uid={3};Pwd={4};",
							settings.Server, settings.Port, settings.Database, settings.Username, settings.Password);
					else
						connStr = String.Format ("Server={0};Database={2};Uid={3};Pwd={3};",
							settings.Server, settings.Database, settings.Username, settings.Password);
						
				}
				connStr = SetConnectionStringParameter (connStr, String.Empty, "Pooling", "false");
				MySqlConnection connection = new MySqlConnection (connStr);
				connection.Open ();
				
				error = null;
				return new MySqlPooledDbConnection (pool, connection);
			} catch (Exception e) {
				error = e.Message;
				return null;
			}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:30,代码来源:MySqlConnectionProvider.cs

示例8: AbstractSchemaProvider

		protected AbstractSchemaProvider (IConnectionPool connectionPool)
		{
			if (connectionPool == null)
				throw new ArgumentNullException ("connectionPool");
			
			this.connectionPool = connectionPool;
			this.supportedActions = new Dictionary<SchemaType, SchemaActions> ();
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:8,代码来源:AbstractSchemaProvider.cs

示例9: Node

        public Node(string host, int port, IConnectionPool masterConnectionPool, params IConnectionPool[] slaveConnectionPools)
        {
            Host = host;
            Port = port;

            _masterConnectionPool = masterConnectionPool;
            _slaveConnectionPools = slaveConnectionPools;
        }
开发者ID:searbe,项目名称:redis-client,代码行数:8,代码来源:Node.cs

示例10: VirtualizedCluster

		public VirtualizedCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider, ConnectionSettings settings)
		{
			this._dateTimeProvider = dateTimeProvider;
			this._settings = settings;
			this._fixedRequestPipeline = new FixedPipelineFactory(settings, this._dateTimeProvider);

			this._cluster = cluster;
			this._connectionPool = pool;
		}
开发者ID:mstoli,项目名称:elasticsearch-net,代码行数:9,代码来源:VirtualizedCluster.cs

示例11: Setup

        public void Setup()
        {
            var mockConnection = new Mock<IConnection>();
            mockConnection.SetupGet(x => x.IsAuthenticated).Returns(false);

            var mockConnectionPool = new Mock<IConnectionPool>();
            mockConnectionPool.Setup(x => x.Acquire()).Returns(mockConnection.Object);

            _connectionPool = mockConnectionPool.Object;
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:10,代码来源:SaslAuthenticationTests.cs

示例12: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     var ipEndpoint = UriExtensions.GetEndPoint(Address);
     var connectionPoolConfig = new PoolConfiguration();
     _connectionPool = new ConnectionPool<EapConnection>(connectionPoolConfig, ipEndpoint);
     _ioStrategy = new DefaultIOStrategy(_connectionPool);
 }
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:7,代码来源:SaslListMechanismTests.cs

示例13: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     var ipEndpoint = UriExtensions.GetEndPoint(_address);
     var connectionPoolConfig = new PoolConfiguration { UseSsl = false };
     _connectionPool = new ConnectionPool<Connection>(connectionPoolConfig, ipEndpoint);
     _ioService = new PooledIOService(_connectionPool);
 }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:7,代码来源:SaslFactoryTests.cs

示例14: OneTimeSetUp

 public void OneTimeSetUp()
 {
     var ipEndpoint = UriExtensions.GetEndPoint(_address);
     var connectionPoolConfig = new PoolConfiguration();
     _connectionPool = new ConnectionPool<Connection>(connectionPoolConfig, ipEndpoint);
     _ioService = new PooledIOService(_connectionPool);
 }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:7,代码来源:SaslListMechanismTests.cs

示例15: SetUp

 public void SetUp()
 {
     var ipEndpoint = UriExtensions.GetEndPoint(Address);
     var factory = DefaultConnectionFactory.GetDefault();
     _configuration = new PoolConfiguration(MaxSize, MinSize, WaitTimeout, RecieveTimeout, ShutdownTimeout, SendTimeout);
     _connectionPool = new DefaultConnectionPool(_configuration, ipEndpoint, factory);
     _connectionPool.Initialize();
 }
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:8,代码来源:DefaultConnectionPoolTests.cs


注:本文中的IConnectionPool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。